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.
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).
Below you can see that the script has now appeared under published. You can see that my customizations have been saved.
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.
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.
Set my Schedule
Select Start to confirm that the Virtual Machines turn on as expected.
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.
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