How to get tenant id in Azure using PowerShell

In this Azure PowerShell article, we will discuss how to get tenant id in Azure using PowerShell, Azure CLI, and Azure Portal.

How to get tenant id in Azure using PowerShell

It is quite simple to find tenant id in Azure using PowerShell using the below Azure PowerShell cmdlet.

 Connect-AzAccount
Get-AzTenant

After executing the above Azure PowerShell cmdlet, I got the below output.

PS C:\WINDOWS\system32>  Connect-AzAccount
Get-AzTenant

Account                   SubscriptionName         TenantId                           
-------                   ----------------         --------                           
fewlines4biju@hotmail.com Visual Studio Enterprise xxxxxxxx-0310-xxxx-xxxb-xxxxxxxx...

Id                    : xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx
TenantId              : xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx
ExtendedProperties    : {[Directory, hotmail.com], [DisplayName, Default Directory], 
                        [TenantCategory, Home], [TenantType, AAD]...}
TenantCategory        : Home
Country               : 
CountryCode           : IN
Name                  : Default Directory
Domains               : {fewlines4bijuhotmail.onmicrosoft.com}
DefaultDomain         : fewlines4bijuhotmail.onmicrosoft.com
TenantType            : AAD
TenantBrandingLogoUrl : 

You can see it below

How to get tenant id in Azure using PowerShell

Read: Azure Powershell change subscription

How to get tenant id in Azure using Azure CLI

You can also find the tenant id using Azure CLI by executing the below cmdlet.

az login
az account list
az account tenant list

After executing the above Azure CLI cmdlet, I got the below output.

{
    "cloudName": "AzureCloud",
    "homeTenantId": "xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx",
    "id": "1gh4300-dee5-4518-5c5c-feaa72a6ghj1",
    "isDefault": true,
    "managedByTenants": [],
    "name": "Visual Studio Enterprise",
    "state": "Enabled",
    "tenantId": "xxxxxxxx-0310-xxxd-xxxb-xxxxxxxxxxxx",
    "user": {
      "name": "fewlines4biju@hotmail.com",
      "type": "user"
    }

You can see it here

How to get tenant id in Azure using Azure CLI

How to find tenant id in Azure Portal

Apart from using Azure PowerShell and Azure CLI, you can also easily get the tenant id in Azure Portal by following the below instructions.

  1. Log in to Azure Portal.
  2. Search for Azure Active Directory and then click on the search result Azure Active Directory.
How to get tenant id in Azure Portal

3. On the Azure Active Directory window, Scroll a bit down, and click on the properties link from the left navigation, you can able to view the tenant id under the Tenant properties as shown below.

How to find tenant id in Azure Portal

You may also like following the below articles

Final Words

Well, in this article we discussed how to find tenant id in Azure using PowerShell, Azure CLI, and Azure Portal. Now it’s your turn to decide which method best suits you.