---
title: "Manage Azure VM Schedules: Control Costs & Efficiency"
description: "Discover how to manage your Azure VM schedules and control costs with scheduled VM startups in this example-driven guide."
canonical: "https://adamtheautomator.com/azure-vm-schedule/"
---

# Manage Azure VM Schedules: Control Costs & Efficiency

> Discover how to manage your Azure VM schedules and control costs with scheduled VM startups in this example-driven guide.

Source: https://adamtheautomator.com/azure-vm-schedule/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Manage Azure VM Schedules: Control Costs & Efficiency](https://adamtheautomator.com/wp-content/uploads/2020/09/Azure-Virtual-Machine.png)

# Manage Azure VM Schedules: Control Costs & Efficiency

[![](https://secure.gravatar.com/avatar/9a14f10ff1b1ec7d790d34f5b559e4d3de2d31b172e6ef266dfd8b479174d97b?s=192&d=mm&r=g)June Castillote](https://adamtheautomator.com/author/june/)3 September 20209 min. read

Categories: [Cloud](/category/cloud/)

Tags:[Azure Automation](/tag/azure-automation/)[Azure Virtual Machines](/tag/azure-virtual-machines/)

Table of Contents

*   [Requirements](#h-requirements)
*   [Planning Ahead](#h-planning-ahead)
*   [Assigning the Azure VM Schedule Tag](#h-assigning-the-azure-vm-schedule-tag)
*   [Assigning the Azure VM Schedule Tag (Azure Portal)](#h-assigning-the-azure-vm-schedule-tag-azure-portal)
*   [Assigning the Azure VM Schedule Tag (Azure PowerShell)](#h-assigning-the-azure-vm-schedule-tag-azure-powershell)
*   [Creating the Azure Automation Runbook](#h-creating-the-azure-automation-runbook)
*   [Creating the PowerShell Script](#h-creating-the-powershell-script)
*   [Creating the Azure Automation Runbook (Azure Portal)](#h-creating-the-azure-automation-runbook-azure-portal)
*   [Creating the Azure Automation Runbook (Azure PowerShell)](#h-creating-the-azure-automation-runbook-azure-powershell)
*   [Testing the Azure Automation Runbook (Azure Portal)](#h-testing-the-azure-automation-runbook-azure-portal)
*   [Publishing and Scheduling the Runbook](#h-publishing-and-scheduling-the-runbook)
*   [Creating a Schedule (Azure Portal)](#h-creating-a-schedule-azure-portal)
*   [Creating a Schedule (Azure PowerShell)](#h-creating-a-schedule-azure-powershell)
*   [Publishing the Runbook (Azure Portal)](#h-publishing-the-runbook-azure-portal)
*   [Publishing the Runbook (Azure PowerShell)](#h-publishing-the-runbook-azure-powershell)
*   [Adding a Schedule to the Runbook (Azure Portal)](#h-adding-a-schedule-to-the-runbook-azure-portal)
*   [Adding a Schedule to the Runbook (Azure PowerShell)](#h-adding-a-schedule-to-the-runbook-azure-powershell)
*   [Summary](#h-summary)
*   [Further Reading](#h-further-reading)

Cost. That’s one of the things to watch out for when managing Azure resources. When you _[generate your Azure usage report](https://adamtheautomator.com/azure-detailed-usage-report/)_, Azure virtual machine usage would probably be the biggest cost contributor. It may be beneficial to create an Azure VM schedule.

Not a reader? Watch this related video tutorial!

**_Not seeing the video? Make sure your ad blocker is disabled._**

You should assess whether your VMs need to be up and running always or if some VMs can be stopped at a specific schedule to save operational costs.

Stopping Azure VMs by schedule is already a built-in feature. This feature allows you to [set a schedule](https://adamtheautomator.com/powershell-scheduled-task/) to gracefully shutdown the Azure VMs to deallocate them. But how do you start those Azure VMs programmatically at a schedule?

To create an Azure VM scheduled start time, you can utilize _[Tags](https://docs.microsoft.com/en-us/rest/api/resources/tags)_ and _[Azure Automation](https://docs.microsoft.com/en-us/azure/automation/automation-intro)_. In this article, you will learn how to use Tags and create a _[PowerShell Runbook](https://docs.microsoft.com/en-us/azure/automation/automation-runbook-types#powershell-runbooks)_ to schedule the startup of Azure virtual machines.

## Requirements

If you plan to do more than just read this article and would want to try out the examples, you need to meet these requirements.

*   Since this article is about Azure VMs, you must have access to an Azure subscription. You can _[request for a free Azure tenant](https://azure.microsoft.com/en-us/free/)_ if you do not have one yet.
*   You should have one or more Azure VMs provisioned in your tenant. These are the VMs that will be the target of this automation. (see: _[Create a Windows virtual machine in Azure](https://docs.microsoft.com/en-us/learn/modules/create-windows-virtual-machine-in-azure/)_).
*   You must have an Azure Automation Account with an Azure Run As account already prepared. If you don’t have this yet, learn how to create one when you go to _[Create a new Automation account in the Azure portal](https://docs.microsoft.com/en-us/azure/automation/automation-create-standalone-account#create-a-new-automation-account-in-the-azure-portal)_.
*   The Azure [PowerShell module](https://adamtheautomator.com/powershell-modules/ "PowerShell module") must be installed. If you don’t have this yet, please go to the _[Install the Azure PowerShell](https://docs.microsoft.com/en-us/powershell/azure/install-az-ps)_ module page for more information.
*   You must have established an Azure session using PowerShell (see: _[Connect-AzAccount](https://docs.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount)_).

## Planning Ahead

As with any project, there are things that you need to plan out for. You will need to define your operating variables, such as the virtual machine name(s), resource group, automation account, and tags.

In this article, the following will be used. It is recommended for you to plan a similar list for your environment.

*   Resource Group Name: _ATA_
*   Virtual Machine Names: _AzVM1, AzVM2_
*   Automation Account Name: _PS-Demo-AA_
*   Automation RunBook Name: _Azure-VM-Schedule-Start-6am_
*   Tags: _StartTime=”6am”_
*   Startup schedule: _06:00:00_

## Assigning the Azure VM Schedule Tag

In ensuring that those with Azure VM schedule will start as part of the automation runbook, the virtual machines must be tagged. Follow the process below to add tags to your target Azure VMs.

In the next sections, you learn how to assign the Azure VM schedule tag using the Azure Portal and PowerShell.

### Assigning the Azure VM Schedule Tag (Azure Portal)

Using the Azure Portal to assign tags to multiple virtual machines is quick and easy. First, _[log in to the Azure Portal](https://portal.azure.com/#home)_. Then, go to **Virtual Machines** and select the virtual machines that will be tagged. In the example below, _AzVM1_ and _AzVM2_ are chosen. After making your selection, click on the **Assign tags** button.

![Azure Virtual Machines are selected for assigning tags](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-98.png)

Azure Virtual Machines are selected for assigning tags

Then, as the **Assign tags** fly-out appears, enter this new tag’s **Name** and **Value** as _StartTime:6am_. Then click on **Save**.

![Assign tags to Azure VMs](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-99.png)

Assign tags to Azure VMs

### Assigning the Azure VM Schedule Tag (Azure PowerShell)

Using the Azure Portal may be easy and convenient, but if hundreds of VMs need to be tagged, you’re far better off using PowerShell.

If you prefer to add tags to your Azure VMs using PowerShell, you can use the code below. Make sure to change the values of the `-Name` and `-ResourceGroupName` parameters to reflect the name of your virtual machine and resource group.

```powershell
## Get the Virtual Machine properties
$azVM = Get-AzVM -Name AzVM1 -ResourceGroupName ATA

## Get the existing tags
$tags = $azVM.Tags

## Add a new tag
$tags += @{StartTime="6am"}

## Apply the new tag collection to the Virtual Machine
Set-AzResource -Name $azVM.Name -ResourceGroupName $azVM.ResourceGroupName  -ResourceType $azVM.Type -Tags $tags
```

After running the code above in Azure PowerShell, you would see a similar output as the image shown below.

![Adding tags to the Azure virtual machine](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-100.png)

Adding tags to the Azure virtual machine

If you need to create the Azure VM schedule tag on other virtual machines, repeat the same steps above but change the name of the target virtual machine. Or, if you want to take things further, you can enhance the script to accept multiple VMs for input so that they are tagged all at once.

## Creating the Azure Automation Runbook

There are two ways to create a runbook. The first way is to create the runbook and then import the script to the runbook. The second way is to import the script, which will automatically create a new runbook if the runbook does not exist yet. In this section, you’ll learn to use the latter, both in the Portal and PowerShell.

### Creating the PowerShell Script

Now, It is time to write the script that will handle the Azure VM scheduled startup. This code will then be imported to the new Azure Automation runbook.

Using your text editor or IDE, copy this code below and save it as _C:\\ATA\\Azure-VM-Schedule-Start-6am.ps1_. Read the comments on top of each line to understand what that line of code does.

```powershell
## Get the Azure Automation Acount Information
$azConn = Get-AutomationConnection -Name 'AzureRunAsConnection'

## Add the automation account context to the session
Add-AzureRMAccount -ServicePrincipal -Tenant $azConn.TenantID -ApplicationId $azConn.ApplicationId -CertificateThumbprint $azConn.CertificateThumbprint

## Get the Azure VMs with tags matching the value '6am'
$azVMs = Get-AzureRMVM | Where-Object {$_.Tags.StartTime -eq '6am'}

## Start VMs
$azVMS | Start-AzureRMVM
```

That’s it. You’ve created the PowerShell script that will be used by the Azure automation runbook later on.

### Creating the Azure Automation Runbook (Azure Portal)

To create a new runbook, in the Azure Portal, go to **Automation Accounts** and click on your automation account where the runbook will be created. In this example, the automation account name is _PS-Demo-AA_.

Then go to the **Runbooks** blade under the Process Automation section, and click on **Upload a runbook.**

![Import a runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154205.270.png)

Import a runbook

The **Import a runbook** fly-out would appear. Click the Browse button and locate the PowerShell script created earlier with the name _C:\\ATA\\AzureVm6amStartTime.ps1._ Once the file is added, click on **Create**.

![Select the runbook script](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154301.076.png)

Select the runbook script

Once the runbook import process is done, you should see the new _Azure-VM-Schedule-Start-6am_ runbook listed in the automation account.

![A new runbook is created](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154424.483-1.png)

A new runbook is created

When you click on the new _Azure-VM-Schedule-Start-6am_ runbook, the runbook properties page will open. Click on the **Edit** button to confirm that your code was imported.

![The new runbook properties](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154530.698.png)

The new runbook properties

As you can see in the below screenshot, the PowerShell script is automatically imported into the runbook.

![PowerShell runbook code](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154620.133.png)

PowerShell runbook code

### Creating the Azure Automation Runbook (Azure PowerShell)

After saving the PowerShell script name _Azure-VM-Schedule-Start-6am.ps1_, the next step is to import the script into a new runbook.

The code below will import the script _C:\\ATA\\Azure-VM-Schedule-Start-6am.ps1_ into a new PowerShell runbook named _Azure-VM-Schedule-Start-6am._ Copy the code below and run it in PowerShell.

```powershell
$runBookSplat = @{
    Name                  = 'Azure-VM-Schedule-Start-6am'
    ResourceGroupName     = 'ATA'
    AutomationAccountName = 'PS-Demo-AA'
    Path                  = 'C:\ATA\Azure-VM-Schedule-Start-6am.ps1'
    Type                  = 'PowerShell'
    Force                 = $true
}
Import-AzAutomationRunbook @runBookSplat
```

After running the code above, the screenshot below shows a similar result.

![Import and create a new PowerShell runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154734.447.png)

Import and create a new PowerShell runbook

## Testing the Azure Automation Runbook (Azure Portal)

Runbooks are created as a _draft_ by default. This allows you more time to test your runbook before finally publishing it.

To test the runbook, open the runbook _Azure-VM-Schedule-Start-6am_ in the **Edit PowerShell Runbook** in the Portal. Then, click on the **Test pane** button.

![Click the Test pane button](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154845.141.png)

Click the Test pane button

Once the Test pane is open, click on the **Start** button to start the testing. Wait until the runbook testing is completed, and you should see the output stream returned.

![Testing the PowerShell runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T154928.022.png)

Testing the PowerShell runbook

As you can see from the result above, the runbook test was completed without errors. Furthermore, when you check the list of VMs that are the targets of this runbook, those VMs should now be _started_.

![The Azure virtual machines are started using the automation runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155050.592.png)

The Azure virtual machines are started using the automation runbook

## Publishing and Scheduling the Runbook

So you have created the runbook and made sure that the runbook works as intended by running a test. What’s left now is to ensure that the runbook is published in Azure. It is scheduled to run daily at 06:00.

In Azure Automation, a schedule is also a shared resource or an asset. Assets can be used or linked with one or more runbooks. Suffice to say, creating a schedule is not the same as assigning a schedule to a runbook. A schedule can only link to a runbook that is published, not draft.

In the next sections, you’ll learn how to create a schedule, publish a runbook, and link the schedule to the published runbook.

### Creating a Schedule (Azure Portal)

In this example, to create a schedule, go to your Automation Account in the Azure Portal, such as _PS-Demo-AA_. Next, go to **Schedules** under the **Shared Resources** section. Once the **Schedules** blade is open, click on the **Add a schedule** button.

![The Add a schedule button](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155129.973.png)

The Add a schedule button

The **New schedule** fly-out should appear at the right-most part of the page. Enter the details of the new schedule to create. In this example, the schedule being created is as follows.

*   Name: _Azure VM Scheduled Startup 6AM Daily_
*   Starts: _August 24, 2020 6:00 AM_
*   Time Zone: _Philippines_
*   Recurrence: _Recurring_
*   Recur every: _1 day_
*   Set expiration: _No_

Once you’ve entered your desired schedule details, click on **Create**.

![The New schedule fly-out](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155208.749.png)

The New schedule fly-out

A new schedule would then appear in the list of schedules indicating that the schedule creation was successful.

![The new schedule asset is created in the Azure Portal](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155242.207.png)

The new schedule asset is created in the Azure Portal

### Creating a Schedule (Azure PowerShell)

If you’d like to create the new schedule asset using PowerShell instead of the Portal, use the code below. Change the values of the schedule properties as you see fit.

```powershell
# Build the schedule parameters
$azSchedule = @{
    Name = 'Azure VM Scheduled Startup 6AM Daily'
    TimeZone = 'Asia/Manila'
    StartTime = (Get-Date 'August 24, 2020 06:00:00 +08:00')
    DayInterval = 1
    ResourceGroupName = 'ATA'
    AutomationAccountName = 'PS-Demo-AA'
}
# Create the schedule
New-AzAutomationSchedule @azSchedule
```

> _Note: Notice that the `TimeZone` value is already provided. Yet the `StartTime` still includes the time offset for that timezone. This is because the `StartTime` value does not automatically consider the `TimeZone` when the schedule is being created for the first time._

After running the above code in PowerShell, you would expect to see a similar result, as shown in the screenshot below.While in the Azure Portal, navigate to the runbook, and open it in Edit mode.

![The new schedule asset is created in Azure PowerShell](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155340.817.png)

The new schedule asset is created in Azure PowerShell

### Publishing the Runbook (Azure Portal)

To publish a runbook in the Azure Portal, navigate to the runbook and open it in Edit mode.

![Open the runbook in Edit mode.](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155414.268.png)

Open the runbook in Edit mode.

Once the runbook is opened in the editor, click on the **Publish** button. You may be prompted whether or not to proceed with publishing the runbook. Click **Yes** to continue.

![Publish the runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155503.478.png)

Publish the runbook

After you’ve published the runbook, you’ll notice that the runbook’s status changed from **New** to **Published**.

![Runbook is published using Azure Portal](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155531.952.png)

Runbook is published using Azure Portal

### Publishing the Runbook (Azure PowerShell)

Runbooks can be published using Azure PowerShell, too. You’ll need to use the code below, just make sure to change the parameter values of `-Name`, `-AutomationAccountName`, and `-ResourceGroup` to match your values.

```powershell
Publish-AzAutomationRunbook `
    -Name 'Azure-VM-Schedule-Start-6am' `
    -AutomationAccountName 'PS-Demo-AA' `
    -ResourceGroup ATA
```

The below image shows the expected output after running the `Publish-AzAutomationRunbook` command above.

![Runbook is published using Azure PowerShell](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155613.512.png)

Runbook is published using Azure PowerShell

Now you’ve published the runbook. You’re now ready to link the runbook to a schedule.

### Adding a Schedule to the Runbook (Azure Portal)

The schedule that was previously created name _Azure VM Scheduled Startup 6AM Daily_ can now be linked to the published runbook. To link the schedule, click on the **Link to schedule** button while in the runbook’s **Overview** blade.

![Link to schedule](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155655.259.png)

Link to schedule

Then, click on **Link a schedule to your runbook.** A list of available schedules will be shown.

![Link a schedule to your runbook](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T155730.007.png)

Link a schedule to your runbook

Next, click on the schedule to be linked to the runbook, such as the _Azure VM Scheduled Startup 6AM Daily_ in this example.

![Select the schedule from the list](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T161320.593-1-1024x167.png)

Select the schedule from the list

After choosing the schedule, click on the **OK** button to finish linking the schedule to the runbook.

![Link the runbook to a schedule using the Azure Portal](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T161431.064.png)

Link the runbook to a schedule using the Azure Portal

### Adding a Schedule to the Runbook (Azure PowerShell)

Using the command below achieves the same result of linking a schedule to a runbook when done in the Azure Portal. Make sure to change the `-Name`, `-ScheduleName`, `-AutomationAccountName`, and `-ResourceGroupName` parameter values appropriately.

```powershell
Register-AzAutomationScheduledRunbook `
    -Name 'Azure-VM-Schedule-Start-6am' `
    -ScheduleName 'Azure VM Scheduled Startup 6AM Daily' `
    -AutomationAccountName 'PS-Demo-AA' `
    -ResourceGroupName 'ATA'
```

And as quick as that, your runbook is now linked to the selected schedule, as you can see from the result below.

![Link the runbook to a schedule using Azure PowerShell](https://adamtheautomator.com/wp-content/uploads/2020/09/Untitled-2020-09-01T161532.253.png)

Link the runbook to a schedule using Azure PowerShell

That’s it. You’re Azure VM scheduled startup is now configured!

## Summary

After reading this article, you have learned how to use Tags and Azure Automation to create a runbook to automate Azure virtual machines’ start-up at a set schedule. You’ve learned the step-by-step process:

*   Assigning tags to virtual machines.
*   Creating, testing, and publishing a draft runbook.
*   Creating a schedule and assigning the schedule to the published runbook.

Best of all, you’ve learned to do all these steps in both the Azure Portal and Azure PowerShell.

With the knowledge you’ve gained in this article, maybe you’re next step is to create a runbook to shut down or stop Azure VMs on schedule, too.

## Further Reading

*   [**_Scheduling Azure Virtual Machine (VM) Startup With Azure Automation And Tags_**](https://www.youtube.com/watch?v=ORsHAR80VUg)
*   [**_Manage an Azure Automation Run As account_**](https://docs.microsoft.com/en-us/azure/automation/manage-runas-account)
*   _[**What is Azure Automation?**](https://docs.microsoft.com/en-us/azure/automation/automation-intro)_
*   **_[Getting Started With Azure Automation: Introduction](https://blog.ipswitch.com/getting-started-with-azure-automation-introduction)_**

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-schedule%2F&text=Manage%20Azure%20VM%20Schedules%3A%20Control%20Costs%20%26%20Efficiency)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-schedule%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fazure-vm-schedule%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/04/featured_image-10.webp)

### [Automate SOC 2 Compliance with PowerShell and Azure](/automate-soc-2-compliance-powershell-azure/)

Learn how to use Azure Policy, the EPAC framework, and PowerShell to automate SOC 2 compliance evidence collection, enforce controls across subscriptions, and build a continuous audit trail.

![](https://adamtheautomator.com/wp-content/uploads/2026/02/featured_image-12.webp)

### [Prevent Azure VM Outages with Load Balancer Health Probes](/distribute-traffic-azure-load-balancer/)

Create a Standard Azure Load Balancer with the Azure CLI, configure health probes and backend pools, and distribute traffic across zone-redundant VMs.

![](https://adamtheautomator.com/wp-content/uploads/2026/02/featured_image-8.webp)

### [Ready to Move Beyond Lift-and-Shift? An Azure Migration ROI Guide](/ready-move-beyond-liftandshift-azure-migration-roi/)

Learn when to move beyond Azure lift-and-shift to PaaS services. Calculate ROI for modernization, optimize costs with Hybrid Benefit, and choose the right migration strategy for SQL Server and web apps.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
