如何查找 Azure Active Directory 租户 IDHow to find your Azure Active Directory tenant ID

Azure 订阅与 Azure Active Directory (Azure AD) 之间存在信任关系。Azure subscriptions have a trust relationship with Azure Active Directory (Azure AD). 订阅信任 Azure AD 对用户、服务和设备执行身份验证。Azure AD is trusted to authenticate users, services, and devices for the subscription. 每个订阅都有一个与之关联的租户 ID,可以通过几种方法查找订阅的租户 ID。Each subscription has a tenant ID associated with it, and there are a few ways you can find the tenant ID for your subscription.

通过 Azure 门户查找租户 IDFind tenant ID through the Azure portal

  1. 登录到 Azure 门户Sign in to the Azure portal.

  2. 选择“Azure Active Directory” 。Select Azure Active Directory.

  3. 选择“属性”。Select Properties.

  4. 然后向下滚动到“租户 ID”字段。Then, scroll down to the Tenant ID field. 你的租户 ID 将显示在框内。Your tenant ID will be in the box.

Azure Active Directory - 属性 - 租户 ID - 租户 ID 字段

通过 PowerShell 查找租户 IDFind tenant ID with PowerShell

你还可以以编程方式查找租户。You can also find the tenant programmatically. 若要使用 Azure PowerShell 查找租户 ID,请使用 cmdlet Get-AzTenantTo find the tenant ID with Azure PowerShell, use the cmdlet Get-AzTenant.

Connect-AzAccount -Environment AzureChinaCloud
Get-AzTenant

有关详细信息,请参阅 Get-AzTenant 的 Azure PowerShell cmdlet 参考。For more information, see this Azure PowerShell cmdlet reference for Get-AzTenant.

通过 CLI 查找租户 IDFind tenant ID with CLI

如果要使用命令行接口查找租户 ID,可以通过 Azure CLIMicrosoft 365 CLI 实现。If you want to use a command-line interface to find the tenant ID, you can do so with Azure CLI or Microsoft 365 CLI.

对于 Azure CLI,请使用 az login、az account list 或 az account tenant list 命令,如以下示例所示 。For Azure CLI, use one of the commands az login, az account list, or az account tenant list as shown in the following example. 注意每个命令的输出中每个订阅的 tenantId 属性。Notice the tenantId property for each of your subscriptions in the output from each command.

az login
az account list
az account tenant list

有关详细信息,请参阅 az login 命令参考、az account 命令参考或 az account tenant 命令参考。For more information, see az login command reference, az account command reference, or az account tenant command reference.

对于 Microsoft 365 CLI,请使用 tenant id 这一 cmdlet,如以下示例所示:For Microsoft 365 CLI, use the cmdlet tenant id as shown in the following example:

m365 tenant id get

有关详细信息,请参阅 Microsoft 365 tenant id get 命令参考。For more information, see the Microsoft 365 tenant id get command reference.

后续步骤Next steps