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

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

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

Windows Azure AD认证支持PowerShell

谢谢


当前回答

步骤1:登录Microsoft Azure门户

步骤2:搜索Azure Active目录

步骤3:单击overview,从租户信息部分找到租户id

其他回答

从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;
}

使用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

访问https://login.windows.net/YOURDIRECTORYNAME.onmicrosoft.com/.well-known/openid-configuration,您将看到一堆包含租户ID的url。

为我工作的是这个(az登录后):

 az account show |grep tenantId | awk {'print $2'} |tr -d '[:punct:]'

进入Azure门户> Azure活动目录。 在主屏幕上,您应该看到您的租户ID。