Starting an Azure VM from the Cloud Shell

I have an Azure Virtual Machine (VM) running in an Azure DevTest Lab that I use as my development machine. The VM will deallocate every evening to save costs and I restart it every morning when I start working. This morning I went to the Azure portal and clicked the start button as usual, but this time it wouldn’t start. I tried multiple times but didn’t get beyond the Starting virtual machine message.

I googled around a bit and found a StackOverflow post suggesting to use Powershell to start the VM. I hadn’t used the Cloud Shell yet, which is available in the portal, so I decided to give that a try.
To my surprise and relieve (I was already dreading a re-install of my dev machine) it only took three Azure CLI commands in the Cloud Shell to get my VM running again.

The first to get a list of all my Azure accounts:

az account list

I looked up the account that hosts my troublesome VM, copied the Id and pasted it into the second command to make the subscription the active one:

az account set --subscription YOUR_ACCOUNT_ID

Now the VM can be started with the third and final command:


Within a couple of seconds the VM was running again.

comments powered by Disqus