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

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

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

Windows Azure AD认证支持PowerShell

谢谢


当前回答

微软表示:

找到你的tenantID:你的tenantID可以通过打开以下metadata.xml文档来发现:https://login.microsoft.com/GraphDir1.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml -用你租户的域值替换"graphDir1.onMicrosoft.com"(租户拥有的任何域都可以)。tenantId是一个guid,它是sts URL的一部分,在第一个xml节点的sts URL(“EntityDescriptor”)中返回:“https://sts.windows.net/”。

参考:

https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-graphapi-web/

其他回答

PowerShell:

Add-AzureRmAccount #if not already logged in 
Get-AzureRmSubscription -SubscriptionName <SubscriptionName> | Select-Object -Property TenantId

如果你已经安装了Azure CLI,你可以运行下面的命令,

az account list

或者在~/.azure/credentials中找到它

微软表示:

找到你的tenantID:你的tenantID可以通过打开以下metadata.xml文档来发现:https://login.microsoft.com/GraphDir1.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml -用你租户的域值替换"graphDir1.onMicrosoft.com"(租户拥有的任何域都可以)。tenantId是一个guid,它是sts URL的一部分,在第一个xml节点的sts URL(“EntityDescriptor”)中返回:“https://sts.windows.net/”。

参考:

https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-graphapi-web/

使用Azure门户:

步骤1:登录azure门户,搜索azure Active Directory并选择它。 Step2:在Azure Active Directory的概览页面中,找到租户ID。

使用Azure CLI:

使用命令az login、az account list或az account tenant list。在每个命令的输出中为每个订阅查找TenantId属性。

使用Powershell

在powershell cmdlet中使用以下命令。

Connect-AzAccount
Get-AzTenant

参考:

Azure CLI

Get-Aztenant

通过PowerShell匿名:

(Invoke-WebRequest https://login.windows.net/YOURDIRECTORYNAME.onmicrosoft.com/.well-known/openid-configuration|ConvertFrom-Json).token_endpoint.Split('/')[3]