How to get the azure account tenant Id?

后端 未结 21 1300
故里飘歌
故里飘歌 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条回答
  • 2020-11-30 18:28

    If you have Azure CLI setup, you can run the command below,

    az account list
    

    or find it at ~/.azure/credentials

    0 讨论(0)
  • 2020-11-30 18:28

    A simple way to get the tenantID is

    Connect-MsolService -cred $LiveCred #sign in to tenant

    (Get-MSOLCompanyInformation).objectid.guid #get tenantID

    0 讨论(0)
  • 2020-11-30 18:29

    You can run a simple curl call to get the tenant id of an azure subscription without any authentication.

    make a curl call to :

    https://management.azure.com/subscriptions/{subscription-id}?api-version=2015-01-01

    The request fails but you will be able to get the tenant id from the response header. The tenant id is present in line followed by "WWW-Authenticate: Bearer authorization_uri="https://login.windows.net/"

    you can use curl -v to show the response header.

    0 讨论(0)
  • 2020-11-30 18:32

    My team really got sick of trying to find the tenant ID for our O365 and Azure projects. The devs, the support team, the sales team, everyone needs it at some point and never remembers how to do it.

    So we've built this small site in the same vein as whatismyip.com. Hope you find it useful!

    https://www.whatismytenantid.com

    0 讨论(0)
  • 2020-11-30 18:33

    Another way to get it from App registrations

    Azure Active Directory -> App registrations -> click the app and it will show the tenant ID like this

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题