Back to ShareGate

How to start and stop virtual machines with Azure Automation

Using an Azure Automation account to automate your virtual machine schedules can go a long way when it comes to resource optimization and cost savings, especially when you don't need to have your VMs running 24/7.

To set up an automated schedule for your Azure VMs, follow these three steps:

  1. Add the Azure Automation service
  2. Configure runbooks
  3. Schedule runbooks

1. Add the Azure Automation service

To get started, you can create a resource group. This isn't mandatory, but it's strongly recommended in order to keep things clean and structured.

To add an automation account (on a VM or a resource group), first click Add to add a new service. Then use the search bar to find Automation. The publisher is Microsoft and the category is Developer tools.

VM start and stop Azure Automation

Create an Automation account. Specify the settings and click Create to add automation account.

If this is the first automation you're creating, choose Yes for Create Azure Run As account.

Create Azure Run as account

2. Configure runbooks

To configure the runbooks, open the Automation account and click Runbooks in the Process Automation submenu.

Next, select Browse Gallery, located in the top menu.

Configure Runbook Azure Automation

Use the search bar to find and import the following runbooks:

  • Start Azure V2 VMs (created by: Azure Automation Product Team)
  • Stop Azure V2 VMs (created by: Azure Automation Product Team)
Start and stop VMs
Import Runbook Azure

Name your runbooks, then edit and publish them. Note that newly imported runbooks default to the New state, but in order to be invoked they must be in a Published state.

Edit Graphical Runbook

3. Schedule the runbooks

Last but not least, it's time to schedule the runbook we just created. To edit the runbook, click Link to schedule.

Create a new schedule and specify the settings to apply. A menu will appear on the right with different settings to define.

Note: The process is the same for automating VM shutdown.

Autostop virtual machine Azure

Once your runbook is scheduled, click Start to make it live. Edit the following parameters, then click Ok:

  • Resourcegroupname: Specify the name of the resource group where the VM resides.
  • Vmname: Specify the name of the VM that you would like to start or stop.

There you have it! Your runbooks are ready and will apply your scheduling automation to the selected VMs.

Optimize your Azure environment for big savings

Looking for ways to save money on Azure? The Ultimate Azure cost optimization checklist for cloud teams will help you thoroughly audit your environment for sources of wasted spend.

You might also like