Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicradon/b880ef766243d0dcfa8c57b57a0137ec to your computer and use it in GitHub Desktop.
Save vicradon/b880ef766243d0dcfa8c57b57a0137ec to your computer and use it in GitHub Desktop.
How to list and set the current active subscription in an Azure CLI shell

Listing subscriptions

For an account, you can list the available subscriptions using the command below:

az account subscription list --output table

It should output something like:

AuthorizationSource    DisplayName                          State    SubscriptionId
---------------------  -----------------------------------  -------  ------------------------------------
RoleBased              Work Subscription                    Enabled  84ddb3d8-dujc-4fac-293s-cd80c0544223
Legacy                 My Azure for Students                Enabled  234562c0-93jd-4231-ldww-efc461364a40

Setting a subscription

You can then set a subscription using the command below:

az account set --subscription 234562c0-93jd-4231-ldww-efc461364a40

The above command sets the current subscription as "My Azure for Students"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment