TIP

💡 Learn more : Azure portal documentation.

How to get the Azure Account Tenant Id?

Your Office 365 tenant ID is a globally unique identifier (GUID) that is different than your tenant name or domain. On rare occasion, you might need this identifier, such as when configuring Windows group policy for OneDrive for Business.

Knowing this, you'll find that there are times when you will want to grab the Tenant Id and while you can do this through PowerShell, sometimes it is just as easy to grab this through the Azure Portal.

The DirectoryId and TenantId both equate to the GUID representing the ActiveDirectory Tenant. Depending on context, either term may be used by Microsoft documentation and products, which can be confusing.

Open the Azure Portal and navigate to Azure Active Directory, then Properties and copy the Directory ID

In other words, the "Tenant ID" IS the "Directory ID".

You can also do this in the Azure CLI:

az account show --subscription a... | jq -r '.tenantId'
az account list | jq -r '.[].tenantId'
1
2

I hope it helps!