我的问题是:不使用powershell命令可以获得azure活动目录租户id吗?

我找到了这两个博客,有了这个帮助,我已经能够从powershell获得租户ID和订阅ID。这是找回房客的唯一方法吗?

在Windows PowerShell中获取Windows Azure活动目录租户ID

Windows Azure AD认证支持PowerShell

谢谢


当前回答

在Azure CLI中(我使用GNU/Linux):

$ azure login  # add "-e AzureChinaCloud" if you're using Azure China

这将要求您通过https://aka.ms/devicelogin或https://aka.ms/deviceloginchina登录

$ azure account show
info:    Executing command account show
data:    Name                        : BizSpark Plus
data:    ID                          : aZZZZZZZ-YYYY-HHHH-GGGG-abcdef569123
data:    State                       : Enabled
data:    Tenant ID                   : 0XXXXXXX-YYYY-HHHH-GGGG-123456789123
data:    Is Default                  : true
data:    Environment                 : AzureCloud
data:    Has Certificate             : No
data:    Has Access Token            : Yes
data:    User name                   : nico@XXXXXXX.onmicrosoft.com
data:    
info:    account show command OK

或者仅仅是:

azure account show --json | jq -r '.[0].tenantId'

或者新的az:

az account show --subscription a... | jq -r '.tenantId'
az account list | jq -r '.[].tenantId'

我希望这对你们有帮助

其他回答

当您浏览给定的Active Directory实例时,租户id也会出现在管理控制台URL中,例如:

https://manage.windowsazure.com/<morestuffhere>/ActiveDirectoryExtension/Directory/BD848865-BE84-4134-91C6-B415927B3AB1

在Azure CLI中(我使用GNU/Linux):

$ azure login  # add "-e AzureChinaCloud" if you're using Azure China

这将要求您通过https://aka.ms/devicelogin或https://aka.ms/deviceloginchina登录

$ azure account show
info:    Executing command account show
data:    Name                        : BizSpark Plus
data:    ID                          : aZZZZZZZ-YYYY-HHHH-GGGG-abcdef569123
data:    State                       : Enabled
data:    Tenant ID                   : 0XXXXXXX-YYYY-HHHH-GGGG-123456789123
data:    Is Default                  : true
data:    Environment                 : AzureCloud
data:    Has Certificate             : No
data:    Has Access Token            : Yes
data:    User name                   : nico@XXXXXXX.onmicrosoft.com
data:    
info:    account show command OK

或者仅仅是:

azure account show --json | jq -r '.[0].tenantId'

或者新的az:

az account show --subscription a... | jq -r '.tenantId'
az account list | jq -r '.[].tenantId'

我希望这对你们有帮助

以下答案来自微软网站,最后更新日期为2018年3月21日:

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal

简而言之,以下是攻略的截图:

选择Azure Active Directory。

要获取租户ID,请为Azure AD租户选择Properties。

复制目录ID。这个值是您的租户ID。

希望这能有所帮助。

使用Azure CLI

az account get-access-token --query tenant --output tsv

For AAD-B2C it is fairly simple. From Azure Portal with a B2C directory associated, go to your B2C directory (I added the "Azure AD B2C" to my portal's left menu). In the B2C directory click on "User flows (policies) directory menu item. In the policies pane click on one of your policies you previously added to select it. It should open a pane for the policy. Click "Properties". In the next pane is a section, "Token compatibility settings" which has a property "Issuer". Your AAD-B2C tenant GUID is contained in the URL.