Getting Started with Azure Automation


As a regular use of an MSDN account with Azure credits, I often find myself running out of credit before I expect and it’s often my own fault. It’s really easy to spin up a server or start experimenting with a service and forget to turn it off or delete it when done. If only a selection of my VMs would turn on during the day and off during the night…. Enter Azure Automation.

 

I looked at Azure Automation when it first came onto the scene, but admittedly struggled with getting it going. The certificate management related to the credentials was challenging, my PowerShell was less than stellar… and I just got frustrated and moved on to something else.

 

But after watching my subscription accidentally drain down to nothing 2 weeks before it reset, I had to revisit Azure Automation. The credential management is much easier now and the PowerShell required to start and stop VMs is minimal.

You’ll need two scripts… one to start and one to stop the desired VMs. You set a schedule for each one and sit back and relax. I’ve also been using GitHub a lot for source control and you can tie Azure Automation into that as well.

My scripts list out each VM I want on the nightly shut down schedule, because I didn’t want to have every VM in my subscription shut down automatically, in case I do have a need to keep something running for more than 24 hours. You may want to customize your scripts differently.

To get started, I recommend following the tutorial in the Azure documentation for “My First Runbook” . It walks you through all the steps of getting your automation account going as well as giving some sample scripts.

If you like to see the basic scripts I’m using for a few of my VMs, you can find them in my GitHub repo.

Automate Away!!


Comments (0)