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

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

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

Windows Azure AD认证支持PowerShell

谢谢


当前回答

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.

其他回答

如果您已经在您的机器中安装了Azure CLI 2.0,那么您应该能够使用以下命令获得您所属的订阅列表:

az login

如果你想看到一个表输出,你可以使用

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

或者你可以使用Rest API

租户-列表|微软文档

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

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

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

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

微软表示:

找到你的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/