Enjoy Sharing

Automating Start/Stop Azure VMs (Resource Manager)

This is part of what I was doing setting up my lab environment entirely in Azure cloud. To save some credits in my subscription I want to make sure my VMs shutdown everyday because we all know a running VM consumes credits. I’m gonna show you one really easy way of doing it without writing any codes.

Once you have logged into your subscription, browse to Automation Accounts and then add a new Automation Account. Here you will be asked for a name, subscription and resource group. Note: I should have named it with something to identify it as an Automation Account, perhaps with a “AA-“ prefix? Click Create.



Once the Automation Account has been created, click on it and then click Runbooks.



At the Runbooks blade, click Browse gallery. Then on the new blade, click Stop Azure V2 VMs. This runbook is created by the SC Automation Product Team.



Click Import.



Pretty simple here. Give it a name then click OK.



Here, click the Edit button.



All you need to do here is click Publish.



At this point you’re almost done except that now you should tell it to run. Without it you would have to kick the runbook off manually. On the runbook, click Schedules, then click Add a schedule.



Here, click Schedule – Link a schedule to your runbook, click Create a new schedule, give it a name, a time and date, click Recurring, set how frequent to run, then click Create.



These settings are totally optional. This is to specify a specific Resource Group, a specific VM and to use a specific Connection Asset. Click OK twice.



Now that you’ve created and configured an automated task to stop all VMs at a specific time of the day, you can now do a similar thing to start all VMs at a specific tome of the day. I normally do this to keep my AD Connect server in sync with Azure AD. So what I normally do as a daily task is to start my VMs up let’s say at 1am everyday and stop all my VMs at 3am everyday to just get everything in sync at the same time saving precious credits when not in use.



You may encounter that your runbooks are not running anymore in the middle of the billing cycle. That’s basically because each Automation Account is configured to use the free tier which will give you 500 job minutes for free. If you do run out of those free minutes, go to the Automation Account > Pricing tier and usage, then click Pricing tier. This way your credits will be consumed to run your runbooks. Don’t worry, from experience it doesn’t cost very much.







Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s