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'.
To switch to the subscription you want to work on execute the command az account set --subscription c56e18b5–23ce-4d2c-ac8c-35d3c9bc7e0f (use your own subscription id).
Sign in to the Azure portal. Under the Azure services heading, select Subscriptions. If you don't see Subscriptions here, use the search box to find it. Find the Subscription ID for the subscription shown in the second column.
To login to the Azure account using Azure CLI, we need to use the az login command. Once you type the az login command, it will prompt for the Azure portal login console. If you need to log in with the device authentication code in the browser, you need to use the parameter –use-device-code.
For anyone finding this question based on the title but with a different problem to the OP.
Symptoms:
az account list
outputaz account set -s subscription_id
fails with error message in titlePossible solution:
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With