az account set subscription

The az account set is an excellent cmdlet that can help you change your active subscription quickly. When you have multiple active Azure subscriptions, during that time, if you wish to set one as an active Azure subscription, this command can help you to fulfill this requirement.

Syntax

The syntax for the az account set command is as follows.

az account set --subscription 'Your subscription name'
az account set --subscription Your subscription id

az account set subscription

If you have multiple Azure subscriptions and wish to set a default Azure subscription, you can use the Az account set command in Azure CLI. Now let’s discuss an AZ account set example.

Example 1: Set your Default Subscription using the Subscription name.

Here, the name of my Azure subscription is ‘Visual Studio Enterprise’. I wanted to make it the default subscription. So, I ran the below command in Azure CLI.

az account set --subscription 'Visual Studio Enterprise'

After executing the above command, I got the below-expected output. Check out the below screenshot for your reference.

az account set --subscription

Example 2: Set your Default Subscription using the Subscription ID.

You can also use your subscription ID instead of your Subscription Name like below. In this example, my subscription ID is ‘1cdf4300-xxxxx-4518-fffff-feaa72a5cbd1’. I wanted to make it the default subscription. So, I ran the command below

az account set --subscription 1cdf4300-xxxxx-4518-fffff-feaa72a5cbd1

After executing the above command, I got the expected output as below. See the below screenshot.

az account set default subscription

You may also like following the below articles

Conclusion

In this article, we discussed the syntax and usage of the Az account set command, which can be used to set your default Azure subscription.