Ignoring VM’s with Stop Start Automation tasks in Azure

Thanks for yesterdays positive comments/questions and retweets.  To follow up after yesterdays post on creating Automated tasks in Azure we will modify the scripts and see what has happened.

Firstly to answer a question, yes you can ignore certain servers if they need to remain on or off.  The only issue I see is if a server is created and to be ignored by this script you will need to update the script each time another server is added to your Azure subscription.

Can you just use group memberships? @Simonster

Let’s change my scripts so Win10Az remains on or off, and must be stopped/started manually (normally).  So go back to Automation, stop script, author, draft, edit, change this line from

Get-AzureVM | where{$_.status -like ‘Stopped*’ } | Start-AzureVM


Get-AzureVM | where{$_.status -like ‘Stopped*’ -and $_.Name -ne ‘Win10Az’} | Start-AzureVM

This is highlighted in the screen grab below.


I ran the stop script and confirmed that only my BenWin10 server powered off.

I then added a similar line of code for my starting script, which you can see below.  I also selected the Start button on this screen.


Then once the start script had finished (90 seconds) I went back to my Virtual Machines view and as below you could see that only BenWin10 was starting up.  Win10Az was ignored when either script ran.



One last point, below is a screen shot of my scripts dashboard, from here you can easily see when the servers were on or off.  This is a great view to ensure your script is working as excepted.



profile pic Aaron Whittaker @AaronW2003



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.


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


profile pic Aaron Whittaker @AaronW2003

Azure RemoteApp going GA next week

With Azure RemoteApp, you can enable your users to access corporate applications from anywhere and on a variety of devices, scale up or down to meet the dynamic business needs.  Azure RemoteApp will be generally available on December 11, 2014. Any Azure RemoteApp instances created during the current public preview period will continue to function as they do today. These instances will automatically transition to a 30-day free trial on December 11, 2014.

@aaronw2003 #tothecloud


Azure and Office 365- One big ecosystem

Here is my recent article “Azure and Office 365- One big ecosystem” published in the @MSAU Microsoft TechNet newsletter.