How to get the azure account tenant Id?

后端 未结 21 1466
故里飘歌
故里飘歌 2020-11-30 17:47

My question is: Is it possible to get the azure active directory tenant id without using powershell command?

I found this two blogs and with this help, I\'m already

21条回答
  •  猫巷女王i
    2020-11-30 18:36

    In the Azure CLI (I use GNU/Linux):

    $ azure login  # add "-e AzureChinaCloud" if you're using Azure China
    

    This will ask you to login 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                   : nico@XXXXXXX.onmicrosoft.com
    data:    
    info:    account show command OK
    

    or simply:

    azure account show --json | jq -r '.[0].tenantId'
    

    or the new az:

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

    I hope it helps

提交回复
热议问题