我的问题是:不使用powershell命令可以获得azure活动目录租户id吗?
我找到了这两个博客,有了这个帮助,我已经能够从powershell获得租户ID和订阅ID。这是找回房客的唯一方法吗?
在Windows PowerShell中获取Windows Azure活动目录租户ID
Windows Azure AD认证支持PowerShell
谢谢
我的问题是:不使用powershell命令可以获得azure活动目录租户id吗?
我找到了这两个博客,有了这个帮助,我已经能够从powershell获得租户ID和订阅ID。这是找回房客的唯一方法吗?
在Windows PowerShell中获取Windows Azure活动目录租户ID
Windows Azure AD认证支持PowerShell
谢谢
当前回答
获取tenantID的简单方法是:
Connect-MsolService -cred $LiveCred #sign in to tenant
(Get-MSOLCompanyInformation).objectid.guid #get tenantID
其他回答
截至目前(06/07/2018),一个简单的方法是在Azure门户中运行Azure云Shell中的az帐户显示(需要存储帐户)。
——命令——
az account show
——命令输出——
{
"environmentName": "AzureCloud",
"id": "{Subscription Id (GUID)}",
"isDefault": true,
"name": "{Subscription Name}",
"state": "Enabled",
"tenantId": "{Tenant Id (GUID)}",
"user": {
"cloudShellID": true,
"name": "{User email}",
"type": "user"
}
}
有关Azure Cloud Shell的更多详细信息,请参阅Azure Cloud Shell | Microsoft Docs概述。
在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'
我希望这对你们有帮助
另一种方法是从应用注册中获取
Azure Active Directory ->应用程序注册->单击应用程序,它将显示租户ID,如下所示
为我工作的是这个(az登录后):
az account show |grep tenantId | awk {'print $2'} |tr -d '[:punct:]'
您可以运行一个简单的curl调用来获得azure订阅的租户id,而无需任何身份验证。
做一个卷曲调用:
https://management.azure.com/subscriptions/{订阅id} ? api版本= 2015-01-01
请求失败,但您将能够从响应报头中获得租户id。租户id出现在一行中,后面跟着“WWW-Authenticate: holder authorization_uri="https://login.windows.net/"
您可以使用curl -v来显示响应头。