tenant I.D. error

Darren 181 Reputation points
2020-08-16T17:49:44.473+00:00

I started to deploy asdk with the following error

Invoke-RestMethod : {"error":"invalid_tenant","error_description":"AADSTS90002: Tenant 'my********.com' not found. This may happen if there are no active subscriptions for the tenant. Check to make sure you have the correct
tenant ID. Check with your subscription administrator.\r\nTrace ID.

I have an azure active subscription I had azure stack working previously but needed to re-deploy to latest version

Azure Stack Hub
Azure Stack Hub
An extension of Azure for running apps in an on-premises environment and delivering Azure services in a datacenter.
188 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,758 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,106 Reputation points Microsoft Employee
    2020-08-21T22:06:23.507+00:00

    @Darren follow these steps to get acquire the token you need in auth header. Also check for any typos in the subscription id that you're using in your Uri.

       # Log in first with Connect-AzAccount if not using Cloud Shell  
         
       $azContext = Get-AzContext  
       $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile  
       $profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)  
       $token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)  
       $authHeader = @{  
           'Content-Type'='application/json'  
           'Authorization'='Bearer ' + $token.AccessToken  
       }  
         
       # Invoke the REST API  
       $restUri = 'https://management.azure.com/subscriptions/{subscriptionId}?api-version=2020-01-01'  
       $response = Invoke-RestMethod -Uri $restUri -Method Get -Headers $authHeader  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.