How To Schedule Auto Stop/Start Azure VM During Off-Hours For Cost-Control

Azure VM Automation to Start and Stop

How To Schedule Auto Stop/Start Azure VM During Off-Hours For Cost-Control

We are going to take a complete Azure VM Automation solution to start and stop during Off-Hours. I’m going to explain to you this automation on the Azure Portal GUI method. In order to configure Azure Virtual-Machines to auto start/stop, we need to create Automation Account and Import the StopAzureV2VM and StartAzureV2VM runbooks from the Azure Gallery.

I would suggest you follow the steps outlined here.

The Azure VM with a  name TM-FS-01 is being used to configure Azure automation.

Azure VM that we are going to automate Stop and Start

The following steps are taken to configure the automation.

  • Create Automation Account.
  • Import Runbooks
  • Schedule Stop and Start VMs with imported runbooks
  • Check the Strat and Stop Runbooks scheduled Jobs

1. Create Azure VM Automation Account

Click the menu icon in Azure Virtual-Machine and Create Resources and search for automation.

Create Resources and search for automation

Search “automation” and select it to create.

Pick Automation from the search result and Create

Pick Automation from the search result and Create

In the Create Automation Account, type name of the Automation Account (One that you choose), Resource Group and Location. Leave the toggle “Create Run as Account” to Yes.

Click Create

Create Automation Account

2. Import Runbooks to Azure Virtual-Machine Automation account

Go to All Resources and open Automation account created.

Go to All Resources in Azure VM Automation

On the automation account, under process automation, select Runbooks.

In order to import runbooks for stop/start automation, select Browse Gallery

Browse gallery for Azure VM Automation

Here, we have to import Start Azure V2 VMs and Stop Azure V2 VMs runbooks.

import Start Azure V2 VMs and Stop Azure V2 VMs runbooks for Azure VM Automation

Select Start Azure V2 VMs and Import and click OK as in the below screen.

Also, do the same steps to import Stop Azure V2 VMs.

import Stop Azure V2 VMs.-Azure VM Automation

After importing the runbooks, we have to publish these runbooks, so that we can schedule VMs Start/Stop automation.

Open each runbook and click Edit. Here we are editing StopAzureV2VM runbook.

Now, we can edit the runbook, click publish, so that the stopazurev2vm runbook will be published.

Next, Open StartAzureV2VM and select edit to publish this runbook.

edit to publish StartAzureV2VM runbook

Click Publish to get the StartAzureV2VM to get published.

Confirm the StopAzureV2VM and StartAzureV2VM runbooks are published by checking status of them.

Here is StartAzureV2VM

3. Schedule Stop and Start VMs with imported runbooks

Open the StopAzureV2VM and Schedule the Azure VM to stop at a specific time. In the Navigation, under resources, select Schedule and Add Schedule in the right.

Select Link a Schedule to your runbook and Create New Schedule.

Type name of the Schedule/Give a Description

Select Date and Time for the VM to Stop and the time Zone relevant to you.

Toggle Recurrence as you want. I have selected Recurring and recur every day for this Example.

Click Create to create the schedule.

Link a Schedule to your runbook and Create New Schedule

Once the Schedule has been configured for Stop VM, now configure parameters and run settings for the VM that you choose to stop at a specific time.

Type the Resource Group name and VM that needs to be automated to stop and click OK to complete Parameters.

Click OK to complete the Schedule Runbook.

configure parameters and run settings for the VM

The StopAzureV2VM has been Scheduled to Stop.

StopAzureV2VM has been Scheduled to Azure VM Automation-Stop

Next, we need to schedule the StartAzureV2VM runbook to start at a specific time the same way we did for Stop Schedule.

Start Azure V2 VM and Schedule the Azure VM

Now, Link a schedule to runbook to automate Start the VM.

 Link a schedule to runbook to automate Start the VM for Azure VM Automation

And, Configure Parameters and run settings for the same VM that we had configured to stop.

configure parameters and run settings for the VM

The StartAzureV2VM runbook has been scheduled and configured.

The StartAzureV2VM runbook has been scheduled and configured.

4. Check the Start and Stop Runbooks scheduled Jobs in Azure Virtual-Machine

The VM Start was completed at the scheduled time.

The VM Start was completed

The Stop job also completed as scheduled.

The configuration of automating the VM to Start and Stop is completed here.

You Can Find Microsoft Documents For Azure here

Please send your feedback in the comments below.

More Articles…

Leave a Reply

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


*