Update 2019-09-09: Add SharePoint REST API

What is a Tenant ID? When you subscribe to Microsoft 365, Microsoft provides you a full environment with several services (SharePoint, Teams, Azure Active Directory, etc.). In order to link all of these services between them and on your environment, they use a unique identifier which is your Tenant ID.

The Tenant ID is represented as GUID: 00000000-0000-0000-0000-000000000000

Generally, you do not need to know your Tenant ID but sometimes, essentially for the developers or when your company needs to deploy an app (ex: enable PowerBI Microsoft 365 Usage Analytics), you need to.

How to retrieve your Tenant ID? Here, some ways to find it!

Azure Active Directory

By default, all the users of your company have access to the Azure Portal.

Once you are connected to your https://portal.azure.com, click on Azure Active Directory, then Properties and this is the Directory ID

Get Microsoft 365 Tenant ID from Azure portal

Microsoft 365 Admin Center

[note]Note

For the users accounts with at least the Reports reader role

Once you are connected to your https://admin.microsoft.com, expand Reports from the left navigation and click on Usage. At the bottom of the page, you should find the Microsoft 365 usage analytics with your Tenant ID.

Get Microsoft 365 Tenant ID from Microsoft 365 Admin Center

SharePoint Admin Center (App permissions)

[note]Note

For SharePoint administrators only

Once you are connected to your SharePoint Admin Center (https://yourdomain-admin.sharepoint.com), click on Classic features from the left navigation, then click on Open under Apps section and click on App Permissions (last link).

On this page, you will see some Apps with a unique identifiers. Each identifier contains a claim with an ID followed by an at ("@") and your Tenant ID (ex: i:0i.t|ms.sp.ext|00000000-0000-0000-0000-000000000000@YOURTENANTID)

SharePoint site

It is a little bit more complex to find the Tenant ID from a SharePoint site but you can do it too.

Web Inspector

Open any modern SharePoint site (or classic) and open the Web Inspector / Web Developer Console

  • On Windows, it is generally F12
  • On MAC OS X, it is generally CMD + OPTION + i

Once opened, launch a search on "siteSubscriptionId"

  • On Windows: CTRL + F
  • On MAC OS X: CMD + F
Get Microsoft 365 Tenant ID from SharePoint site

Rest API URL

Firstly, open your favorite web browser and go to any SharePoint site collection then, edit the URL like this:

https://contoso.sharepoint.com/sites/mysite/_api/SP.UserProfiles.PeopleManager/GetMyProperties
[note]Note

Replace contoso by your own domain name.

the result will be a little bit huge... But perform a search on "SPS-DistinguishedName":

Get Microsoft 365 Tenant ID from SharePoint REST API

here an example of the value (the first OU correspond to your Tenant ID):

CN=00000000-1111-2222-3333-444444444444,OU=[YOUR TENANT ID],OU=Tenants,OU=MSOnline,DC=SPODS0123456789,DC=msoprd,DC=msft,DC=net

Teams

All the users who have a Microsoft Teams license can reach their https://portal.office.com and click on the Teams tile or access it directly from their Desktop application.

Once connected to the application (web or desktop), you can show your Tenant ID by sharing:

  • Team
  • Channel

Click on the ellipsis on the right of Team or Channel and click on Get a link ...; at the end of the URL, you will see your Tenant ID.

PowerApps

All the users who have a PowerApps license can reach their https://portal.office.com and click on the PowerApps tile.

Once redirected to the PowerApps home page, the Tenant ID is visible from the URL.

Flow

All the users who have a Microsoft Flow license can reach their https://portal.office.com and click on the Flow tile.

Once redirected to the Microsoft Flow home page, click on My Flows from the left navigation, and the Tenant ID is visible from the URL.

Stream

[note]Note

For Stream administrators only

All the users who have a Microsoft Stream license, can reach their https://portal.office.com and click on the Stream tile or directly from the URL https://web.microsoftstream.com/.

Once redirected to the Microsoft Stream home page, click on Settings (gear) from Microsoft 365 top bar then, click on Admin settings link.

From the left navigation, expand Manage Stream and click on eCDN provider.

Get Microsoft 365 Tenant ID from Microsoft Stream

Office365-CLI

Once logged to your environment, the following command will return your Tenant ID:

tenant id get --domainName mydomain.onmicrosoft.com

and the result is:

Get Microsoft 365 Tenant ID with Office365-CLI

Azure CLI

The only thing you have to do is to connect into your environment with the following command:

az login

once connected, the result is:

Get Microsoft 365 Tenant ID with Azure CLI

Azure Active Directory PowerShell

The only thing you have to do is to connect into your environment with the following cmdlet:

$AzCreds = Get-Credential
Connect-AzureAD -Credential $AzCreds

and the result is:

Get Microsoft 365 Tenant ID with Azure Active Directory PowerShell module

SPFx

For the developers who need to use the Tenant ID in their SharePoint Framework components, you will find it like that:

this.context.pageContext.aadInfo.tenantId._guid



Hoping this post will help you πŸ˜‰

You may also be interested in