Reducing your monthly Azure spend through Automation tasks

Azure has an Azure automation engine to allow you to author and run automated tasks with little scripting experience required.  These tasks are in a Runbook (PowerShell workflows).  This allows you to talk to VM’s at the infrastructure level and also inside VM’s operating systems including Linux VM’s.  At the time of writing there were 119 templates to use.

Let’s get some extra value out of having VM’s in Azure.  Let’s automatically turn off our dev/test vm’s at the end of each day.  This will save money by having the servers powered off overnight.

Within the Runbook automation gallery, filter by VM lifecycle management.  Select Azure automation workflow to schedule stopping of all Azure Virtual Machines.

1

Select the tick button to Import

Go and create credentials under assets.

Go and edit imported task and select Author, modify your credentials to the new credentials that you added, add your subscription name (find this under VM’s tab, or subscriptions at the top), and change the script to ‘not stop’ any VM’s that need to remain on (this can be done through several types of filters).

Publish

Below you can see that the script has now appeared under published.  You can see that my customizations have been saved.

2

Now select Start and Yes, after 20-30 seconds (depending how many servers you have) assuming your job runs successfully, go to the Virtual Machines tab refresh your browser.  You will see my BenWin10 VM has stopped.

3

Then I created a schedule for this to occur every night at 7:30 pm.  Select the task and then select schedule, “link to a new schedule”.  Be sure to adjust for time zones/daylight savings if necessary.

Now go and replicate the same steps to create a task to turn the servers back on each morning.  I utilised the “Azure Automation Workflow to Schedule starting of all Azure Virtual Machines” script.

4

Set my Schedule

5

Select Start to confirm that the Virtual Machines turn on as expected.

6

After 20-30 seconds assuming your job runs successfully, go to the Virtual Machines tab refresh your browser.  You will see your servers have successfully turned back on.

If you want to confirm things are working as expected, just check on the dashboard.

7

 

Refer to this blog for updates HERE

Refer to this @MSAU #LevelUpAzure video to watch a recorded demo with Rick Claus @RicksterCDN, Joe Levy HERE

 

profile pic Aaron Whittaker @AaronW2003

Advertisements

2 thoughts on “Reducing your monthly Azure spend through Automation tasks

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