In the Azure CLI, you can use GNU/Linux):
$ azure login # add "-e AzureChinaCloud" if you're using Azure China
This will ask you to log in via https://aka.ms/devicelogin or https://aka.ms/deviceloginchina
$ azure account show
info: Executing command account show
data: Name : BizSpark Plus
data: ID : aZZZZZZZ-YYYY-HHHH-GGGG-abcdef569123
data: State : Enabled
data: Tenant ID : 0XXXXXXX-YYYY-HHHH-GGGG-123456789123
data: Is Default : true
data: Environment : AzureCloud
data: Has Certificate : No
data: Has Access Token : Yes
data: User name : [email protected]
data:
info: account show command OK
Are you interested in learning Azure from basics! Refer to this video on Azure provided by Intellipaat:
Or else, you can do this:
azure account show --json | jq -r '.[0].tenantId'
Or you can use the new az:
az account show --subscription a... | jq -r '.tenantId'
az account list | jq -r '.[].tenantId'