Sequentially Start & Stop Azure VMs – Azure Automation

Following on from my previous blog post, this is how I managed to sequentially start and stop Azure VMs (Virtual Machines) by using Azure Automation.

First thing you need to do is setup an Azure Automation account – good news if you’re a light user, this is free!

You will need to create some assets:


The two assets you need to create are credentials and a subscription automation variable.

The credentials the most important part to this for obvious reasons and just like in my previous post, you can’t use a Microsoft account here, you need to create for yourself an organisational based account in Azure setup as a co-administrator (Azure ASM) or contributer (Azure ARM).

Setting up the credential asset:


Setting up the ‘subscription’ automation variable asset:


Next thing to do is setup a new runbook, make sure you choose ‘PowerShell Workflow‘.

Do this step twice, one runbook to Start VMs and another runbook to Stop VMs.


Then go through and edit the runbooks, copy and past the following code.

Start VMs:

Stop VMs:


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: