We are in 2021 and most companies have somewhat started to use some cloud services. Might it be only for E-Mail, or Google Maps or the likes of Azure – nowadays it is almost everywhere. After some time, you might even end-up with multiple subscriptions and always end-up with the wrong one when logging into the Azure Portal… does this sound familiar huh?
Of course, you can easily change the subscription or use features like “Filter by directory”. However, there is also a way to permanently change this and set your new default subscription.
For this, I use Azure CLI which can be downloaded here. I used the CLI from a Windows Command Prompt. To change the subscription, open a Command Prompt and login to your subscription by typing az login
Then you want to get a list of all the available subscriptions with your account: az account list
. Pay attention to the “isDefault” value, this is probably set to “false” for your subscription, right?
To change the subscription, you can use the subscription name or better the ID:
Subscription Name: az account set --subscription "MSDN Azure Subscription"
or
Subscription ID: az account set -s “a3b303c4-6120-4313-be66-f5b5af2a3cg4”
After this, the “MSDN” subscription has become my new default subscription. Very simple and straight forward and will save you 10 seconds from now on after every login.
It doesn’t stick for me, sadly. Have to do it every time. Presumably a permission thing.
Same here. Not working permanently. On azure-cli 2.42.0.
It is Oct 2023 and with az cli version 2.53.0 this does not work on MacOS. Default subscription always gets reset.
I think it works if you’re using Az CLI (or Az PowerShell) locally; but it doesn’t work in Azure Cloud Shell.