Technology Enthusiast, Software Engineer & Craftsman, DevOps Human & All Round Disney Lover

Using the Azure Cloud Shell with Multiple Subscriptions

Using the Azure Cloud Shell with Multiple Subscriptions

Dan Horrocks-Burgess
Dan Horrocks-Burgess

If you’re working with Azure, then chances are you’ve used the Azure Cloud Shell. This handy tool means you can run azure commands from a couple of clicks from within the portal. But if you have multiple subscriptions in Azure (Perhaps a Visual Studio (MSDN) subscription & a work development account?) then you may run commands and get unexpected errors.

I fell on this exact problem today. I was working with a newly built AKS cluster, obtaining the credentials to inspect the cluster was command number one! Unfortunately as soon as I ran the command:

az aks get-credentials --resource-group danhb-aks-testing --name danhb-kub01

I got the error “Resource group ‘danhb-aks-testing’ could not be found.”

It turns out that the azure cli is set to run against a single subscription at a time, thankfully for us it’s very simple to switch the targeted subscription. The below commands list all available subscriptions and switch subscription respectively.

az account list --output table
az account set --subscription "PAYG Dev/Test"

Make sure you swap out your subscription name in the 2nd command!