IT story

Azure 계정 테넌트 ID를 얻는 방법은 무엇입니까?

hot-time 2020. 5. 23. 09:03
반응형

Azure 계정 테넌트 ID를 얻는 방법은 무엇입니까?


내 질문은 : powershell 명령을 사용하지 않고 푸른 활성 디렉토리 테넌트 ID를 얻을 수 있습니까?

이 두 개의 블로그를 찾았으며이 도움말을 통해 이미 Powershell에서 테넌트 ID 및 구독 ID를 얻을 수 있습니다. 테넌트를 검색하는 유일한 방법입니까?

Windows PowerShell에서 Windows Azure Active Directory 테넌트 ID 가져 오기

PowerShell에 대한 Windows Azure AD 인증 지원

감사


시간은 모든 것을 바꿉니다. 나는 최근에 똑같이하고 싶었고 이것을 생각해 냈습니다.

노트

추가됨 12/18/2017

shadowbq로 표시된 것처럼 DirectoryId 및 TenantId는 ActiveDirectory Tenant를 나타내는 GUID와 동일합니다. 상황에 따라 Microsoft 문서 및 제품에서이 용어를 사용할 수 있으므로 혼동 될 수 있습니다.

가정

  • Azure Portal에 액세스 할 수 있습니다

해결책

테넌트 ID는 Azure의 ActiveDirectoy에 연결되어 있습니다.

  • 대시 보드로 이동
  • ActiveDirectory로 이동
  • 관리 / 속성으로 이동
  • "디렉토리 ID"를 복사하십시오.
  • 이익

Azure ActiveDirectory 테넌트 ID

예, 페인트를 사용했습니다. 판단하지 마십시오.


https://login.windows.net/YOURDIRECTORYNAME.onmicrosoft.com/.well-known/openid-configuration으로 이동하면 테넌트 ID가 포함 된 여러 URL이 표시됩니다.


우리 팀은 O365 및 Azure 프로젝트 테넌트 ID 를 찾으려고 노력 했습니다. 개발자, 지원 팀, 영업 팀 등 모든 사람이 특정 시점에 필요하며 수행 방법을 기억하지 않습니다.

그래서 우리는 whatismyip.com과 같은 맥락에서이 작은 사이트를 구축했습니다. 유용하다고 생각하십시오!

https://www.whatismytenantid.com


테넌트 ID는 주어진 Active Directory 인스턴스를 탐색 할 때 관리 콘솔 URL에도 나타납니다.

https://manage.windowsazure.com/<morestuffhere>/ActiveDirectoryExtension/Directory/BD848865-BE84-4134-91C6-B415927B3AB1

Azure Mgmt 콘솔 Active Directory


Azure CLI에서 (GNU / Linux를 사용합니다) :

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

https://aka.ms/devicelogin 또는 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

또는 간단히 :

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

또는 새로운 az :

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

나는 그것이 도움이되기를 바랍니다


오래된 방법에 새로운 방법을 추가하기 만하면됩니다 (그러나 여전히 관련성 높은 질문). 새 포털에서 아무 화면에서나 도움말 아이콘을 클릭하고 ' 진단 표시 '를 선택 하면 TenantId, Tenant Name 및 훨씬 더 유용한 정보를 포함한 모든 테넌트 정보가 포함 된 JSON 문서가 표시됩니다.

여기에 이미지 설명을 입력하십시오


이 답변은 Microsoft 웹 사이트에서 제공되었으며 2018 년 3 월 21 일에 마지막으로 업데이트되었습니다.

https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal

간단히 말해 다음은 연습의 스크린 샷입니다.

  1. Azure Active Directory를 선택하십시오.

Azure Active Directory

  1. 테넌트 ID를 얻으려면 Azure AD 테넌트의 속성을 선택하십시오.

속성 선택

  1. 디렉토리 ID를 복사하십시오. 이 값은 테넌트 ID입니다.

디렉토리 ID를 복사하십시오. 이것은 테넌트 ID입니다.

도움이 되었기를 바랍니다.


익명으로 PowerShell을 통해 :

PS C:\> (Invoke-WebRequest https://login.windows.net/YOURDIRECTORYNAME.onmicrosoft.com/.well-known/openid-configuration|ConvertFrom-Json).token_endpoint.Split('/')[3]

앱 등록에서 얻는 또 다른 방법

Azure Active Directory-> App registrations-> 앱을 클릭하면 다음 tenant ID과 같이 표시됩니다

여기에 이미지 설명을 입력하십시오


현재 (2018 년 6 월 7 일 ) Azure 포털 에서 Azure Cloud Shell (스토리지 계정 필요)에서 z 계정 쇼실행하는 쉬운 방법이 있습니다 .

--- 명령 ---

az account show

--- 명령 출력 ---

{
  "environmentName": "AzureCloud",
  "id": "{Subscription Id (GUID)}",
  "isDefault": true,
  "name": "{Subscription Name}",
  "state": "Enabled",
  "tenantId": "{Tenant Id (GUID)}",
  "user": {
    "cloudShellID": true,
    "name": "{User email}",
    "type": "user"
  }
}

https://docs.microsoft.com/en-us/azure/cloud-shell/overview 에서 Azure Cloud Shell에 대한 자세한 내용을 찾으십시오 .


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.


In PowerShell:

Add-AzureRmAccount #if not already logged in 
Get-AzureRmSubscription -SubscriptionName <SubscriptionName> | Select-Object -Property TenantId

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

az account list

or find it at ~/.azure/credentials


Use the Azure CLI

az account get-access-token --query tenant --output tsv

From Java:

public static String GetSubscriptionTenantId (String subscriptionId) throws ClientProtocolException, IOException
{
    String tenantId = null;
    String url = "https://management.azure.com/subscriptions/" + subscriptionId + "?api-version=2016-01-01";

    HttpClient client = HttpClientBuilder.create().build();
    HttpGet request = new HttpGet(url);
    HttpResponse response = client.execute(request);

    Header[] headers = response.getAllHeaders();
    for (Header header : headers)
    {
        if (header.getName().equals("WWW-Authenticate"))
        {
            // split by '"' to get the URL, split the URL by '/' to get the ID
            tenantId = header.getValue().split("\"")[1].split("/")[3];
        }
    }

    return tenantId;
}

According to Microsoft:

Find your tenantID: Your tenantId can be discovered by opening the following metadata.xml document: https://login.microsoft.com/GraphDir1.onmicrosoft.com/FederationMetadata/2007-06/FederationMetadata.xml - replace "graphDir1.onMicrosoft.com", with your tenant's domain value (any domain that is owned by the tenant will work). The tenantId is a guid, that is part of the sts URL, returned in the first xml node's sts url ("EntityDescriptor"): e.g. "https://sts.windows.net/".

Reference:

https://azure.microsoft.com/en-us/resources/samples/active-directory-dotnet-graphapi-web/


You can also get the tenant id, in fact all subscription details by logging into the url resources.azure.com


A simple way to get the tenantID is

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

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


For AAD-B2C it is fairly simple. From Azure Portal with a B2C directory associated, go to your B2C directory (I added the "Azure AD B2C" to my portal's left menu). In the B2C directory click on "User flows (policies) directory menu item. In the policies pane click on one of your policies you previously added to select it. It should open a pane for the policy. Click "Properties". In the next pane is a section, "Token compatibility settings" which has a property "Issuer". Your AAD-B2C tenant GUID is contained in the URL.


If you have installed Azure CLI 2.0 in your machine, you should be able to get the list of subscription that you belong to with the following command,

az login

테이블 출력으로보고 싶다면 그냥 사용할 수 있습니다.

az account get-access-token --query tenant --output tsv

또는 Rest API를 사용할 수 있습니다

https://docs.microsoft.com/en-us/rest/api/resources/tenants/list


xxx@Azure:~$ az ad sp create-for-rbac
Retrying role assignment creation: 1/36
{
  "appId": "401143c2-95ef-4792-9900-23e07f7801e7",
  "displayName": "azure-cli-2018-07-10-20-31-57",
  "name": "http://azure-cli-2018-07-10-20-31-57",
  "password": "a0471d14-9300-4177-ab08-5c45adb3476b",
  "tenant": "e569f29e-b008-4cea-b6f0-48fa8532d64a"
}

참고 URL : https://stackoverflow.com/questions/26384034/how-to-get-the-azure-account-tenant-id

반응형