azureazure-cloud-shell

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'.


Solution

  • Test the link you posted and get the same error, the screenshot below: enter image description here

    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: enter image description here