简体   繁体   中英

The subscription of xxx' doesn't exist in cloud 'AzureCloud'

I'm trying to follow the example of how to Install and configure Terraform to provision VMs and other infrastructure into Azure using Azure Cloud shell as described here :

The following command provided the subscription id and tenant id:

az account show --query "{subscriptionId:id, tenantId:tenantId}"

However, the command provided the following error:

The subscription of '' doesn't exist in cloud 'AzureCloud'.

For anyone finding this question based on the title but with a different problem to the OP.

Symptoms:

  • subscription isn't showing in az account list output
  • az account set -s subscription_id fails with error message in title

Possible solution:

  • You need to re-auth the cli with az login

Just log in again

az login

That will update the subscriptions you belong.

Test the link you posted and get the same error, the screenshot below: 在此处输入图片说明

It seems that because you are log in to Azure Portal and there is a tenant which you also logged in. If the tenant only has one subscription, then you set the subscription in another tenant with the command az account set --subscription="${SUBSCRIPTION_ID}" , you will get the error:

The subscription of 'xxxx' doesn't exist in cloud 'AzureCloud'

You needn't use the command az account set --subscription="${SUBSCRIPTION_ID}" if the tenant only has one subscription. If you want to use, please use the subscription Id show you. The test result as the screenshot below: 在此处输入图片说明

Faced same problem today. Ran the following commands in below sequence

connect-azaccount az account list --all --output table

I could not see the new subscription where I was given access today only tried to run connect-azaccount multiple times. This was very frustrating. Then I drank a cup of coffee and ran the below command

az login

Then I ran the below command again

az account list --all --output table

Now I could see all the subscriptions including the one where I was added today.

I am very happy now.

You probably have multiple accounts and want to access a subscription that's available under a different account from the one that you are currently logged in. So, run az logout then run az login which will open your browser so you can login to azure! now select the account you want to use and login. This will resolve the issue as it did for me.

first go to your machine and type az login It will give you one url, copy and past it on browser , it will ask code which you will fins it on your machine where you execute az login command just copy and past. This process will ask you your azure account detail to verify, give your azure account info. After successful verification close window. then execute below command az account set --subscription **************************** az aks get-credentials --resource-group ********* --name *********

Now you connected to your azure K8 cluster

I experienced this when using Azure cli through the AzureCLI@2 task, eg:

- task: AzureCLI@2
  displayName: 'My task'
  inputs:
    azureSubscription: my-subscription
    scriptType: ps
    scriptLocation: inlineScript
    arguments:
      -c container-name `
      --account-name my-account
    inlineScript: |
      az storage blob lease break -b terraform.tfstate

The executing server had Azure cli v.2.0.69 installed, and the error went away after upgrading the CLI to the newest version (2.27.2 as of writing).

I'm not sure if this really pertains to this question, but this is where I landed while debugging a similar error message, so if anybody else runs into this same issue, the problem I had was that I had run the command with sudo . After running it as my normal user, it worked fine.

Sometime re-login (az login) also does not work. Try something like:

  1. (Here, when you paste the Login URL & Code, then try to use Browser Incognito mode)

  2. It worked for me.

    b) sudo<\/strong> az account set --subscription Your Subscription ID<\/strong> c) sudo<\/strong> az acr login -n Your Container Registry Name<\/strong> (You use your desired command instead of this acr command)

I was running into this error in an Azure DevOps build pipeline using the Azure CLI task and a manual service connection. My issue was that my new service principal had no perms to anything in the subscription. As soon as I gave it contributor access to the resource group where I wanted to deploy to, the error disappeared.

"

使 chrome 默认浏览器对我有用。

"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM