是否有 API 可用于获取资源所在的租户名称?我知道资源组和订阅。
到目前为止,我发现的只是一种列出所有租户的方法https://management.azure.com/tenants?api-version=2017-08-01但我仍然不知道如何将此信息与 Azure 连接资源
是否有 API 可用于获取资源所在的租户名称?我知道资源组和订阅。
到目前为止,我发现的只是一种列出所有租户的方法https://management.azure.com/tenants?api-version=2017-08-01但我仍然不知道如何将此信息与 Azure 连接资源
AFAIK,如果你想使用 rest api 来做到这一点,似乎我们可以只使用 MS graph api:获取组织或 AAD 图GET https://graph.windows.net/{tenant id}/tenantDetails?api-version=1.6
来获取租户名称,但它只是获取当前经过身份验证的租户。
如果您想通过资源获取租户名称,您可以使用 azure powershell 来执行此操作。如您所知,请具体说明-SubscriptionId
资源在哪个订阅中。
$TenantId = (Get-AzureRmSubscription -SubscriptionId "xxxx").TenantId
Connect-AzureAD -TenantId $TenantId
Get-AzureADTenantDetail
是DisplayName
租户名称。
主要端点是https://graph.microsoft.com/v1.0/organization
示例代码(Node.js):
const info_tenant = await apiRequestFunction(`https://graph.microsoft.com/v1.0/organization`, 'GET', null, {
"Authorization": access_token,
"Content-Type": "application/json"
});
返回组织信息,info_tenant.value[0].displayName
租户名称在哪里。