Start & Stop Azure VM Automatically

With all the benefits of using Virtual Machines on Azure, one of challenge is to manage the cost of running it. It becomes important especially for developers and consultants as they may not need the virtual machines to run all day.

Using Azure Automation, you can schedule the start and stop timings for your virtual machines easily. The article descries the steps you may need to follow to achieve this.

Add Automation Service

  • Create a Resource Group (optional).
  • In the resource group, click Add to add a new service.
  • Search for Automation.

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

NOTE:
Select Yes in the “Create Azure Run as Account” option, if this this the first automation you are creating.

Configure Runbooks

  • Open the Automation account, you just created.
  • Click Runbooks, under Process Automation.

NOTE: In case there are default published runbooks, you can delete them (optional).

  • Click Browse Gallery.

  • Search and Import the following Graphical Runbooks:
    • Start Azure V2 VMs
    • Stop Azure V2 VMs

  • Specify Name for your runbooks.
  • Edit the runbooks and Publish them.

Schedule the Runbook

  • Edit the Runbook.
  • Click Schedule.

  • Create a new schedule and specify the settings. The image below shows the settings for Starting the VM.

NOTE: Similarly, you can also provide scheduling settings for stopping the VM.

  • Click Start to start the runbook. Specify the following parameters and click Ok:
    • RESOURCEGROUPNAME: Specify the name of the resource group where the VM resides.
    • VMNAME: Specify name of the VM that you would like to start or stop.
    • AZURECONNECTIONASSETNAME: (optional)

The runbooks are ready and will start and stop the VMs on scheduled timings as per your settings.

NOTE: If you are using a public IP, this will change every time the VM starts. Its better to setup a DNS Name and use that in your RDP to connect to the VM.

That’s it, enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.