我的问题是:不使用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
谢谢
当前回答
当您浏览给定的Active Directory实例时,租户id也会出现在管理控制台URL中,例如:
https://manage.windowsazure.com/<morestuffhere>/ActiveDirectoryExtension/Directory/BD848865-BE84-4134-91C6-B415927B3AB1
其他回答
一键回答:
打开这个URL:
https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Properties
时间会改变一切。我最近也想做同样的事情,然后想到了这个:
Note
添加02/17/2021
稳定的门户页面感谢Palec
添加12/18/2017
正如shadowbq所指出的,DirectoryId和TenantId都等同于表示ActiveDirectory租户的GUID。根据上下文的不同,这两个术语都可能被Microsoft文档和产品使用,这可能会令人困惑。
假设
您可以访问Azure传送门
解决方案
租户ID绑定到Azure中的ActiveDirectoy
导航到仪表板 导航到ActiveDirectory 导航到管理/属性 复制“目录ID”
Azure ActiveDirectory租户ID:
在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'
我希望这对你们有帮助
从Java:
public static String GetSubscriptionTenantId (String subscriptionId) throws ClientProtocolException, IOException
{
String tenantId = null;
String url = "https://management.azure.com/subscriptions/" + subscriptionId + "?api-version=2016-01-01";
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
Header[] headers = response.getAllHeaders();
for (Header header : headers)
{
if (header.getName().equals("WWW-Authenticate"))
{
// split by '"' to get the URL, split the URL by '/' to get the ID
tenantId = header.getValue().split("\"")[1].split("/")[3];
}
}
return tenantId;
}
您还可以通过登录url resoures.azure.com获得租户id,实际上是所有的订阅详细信息