Azure Automation – Automate your Development VMs

Microsoft is offering more than 200 cloud services. Azure Automation is very powerful service in Microsoft Cloud to automate other services.
For example Azure Automation can help in order to automate

  • Auto space provisioning/ Backup Restore space
  • VM’s availability in specific hours (On Prem/Cloud)
  • Notify users of underutilized VMs and perform remediation
  • Alert on a VM then turn on tracing, collect logs, upload to Azure Storage and make available in Visual Studio for troubleshooting
  • Deploy a new service to Azure and configure the end points for CPU and Memory alerts

There are many stuff you can automate but in below i will automate on scenario

Scenario: Azure Dev VM’s required only in office hours (9:00 AM – 5:00 PM). That automation will save your VM consumption time significantly. You don’t need to Start/Stop manually VM’s daily. Here is step by step guide

1. Open  Azure Portal with URL https://portal.azure.com

2. Click on more services

3. Search with name “Automation” you will found (Automation Account)

4. Click “Add” to create new “Automation Account”
5. Provide necessary details like name, Subscription, Resource Group, Location etc as in example its “TariqAzureAutomationAccount”
6. After you press create button you can see bell sign for status either created or not yet
7. In below image Automation Account created
8. Click on created automation account for details and here you can see “RunBooks”, Click on “RunBooks”
9. This will redirect to page shown below to create new “RunBook”
10. Provide details like Name, Type as shown below
11. After some seconds you can see “RunBook” created
12. Click on newly created RunBook as in my example is “MyTestRunBook”, click Edit button 
13. This is called Canvas where you can write code, here i pasted Connection String. This will handle authentication with Automation Run As account
 $Conn = Get-AutomationConnection -Name AzureRunAsConnection 
Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID `
-ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint

14. On left side you can find PowerShell commands available for further actions
15. In my example we want to start Azure Development VM, so selected “Start VM” command by doing right click and add to canvas
16. This will looks like this



17. Put your VM name and Resource Group Name as shown below

18. After save, click on start


19. After some moments this will show you status like below 
20. Now save and click Publish

21. Once you click Publish option will give you alert

22. Window will looks like below and you can set schedule for your job

23. Click on Schedule in order to create new schedule

24. In below example name of schedule is “StartDailyVMs” and start time is 9:00 AM



25. You can see schedule has been created and “Status” is On

26. Schedule is already done and job will be executed next day morning at 9:00AM but here you run job forcefully also


 27. After job i can see status of my existing virtual machine “TestVM1” is changed from “Stopped” to “Starting”

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

Blog at WordPress.com.

Up ↑

%d bloggers like this: