Backup Azure Virtual Machines with Azure Automation

In this blog post, I will show you how to Backup Azure Virtual Machines with Azure Automation.

Azure Automation

Azure Automation is a cloud-based automation service that is offered by Microsoft Azure. It allows you to automate repetitive, manual, and time-consuming tasks across Azure and other third-party systems.

With Azure Automation, you can create, deploy, monitor, and maintain resources in your Azure environment. This service enables you to automate tasks using workflows, runbooks, and PowerShell scripts. You can schedule these automation tasks, or trigger them based on certain events.

Azure Automation helps you to streamline your IT operations and reduce the risk of errors that are caused by manual tasks. It also helps to improve the efficiency of your operations and allows you to focus on more strategic initiatives.

Some of the common use cases of Azure Automation include automating VM management, patching and updates, backup and recovery, and configuring networking and security settings.

Backup Azure Virtual Machines with Azure Automation

The reason I am using Azure automation to back up my VM is because Azure Recovery services backup policies allow one backup per day.

In my case, I need to back up the VM two times a day and use Azure automation. I can add another backup per day.

Create Automation Account

I created an automation account with an Azure Run As account (default) to get started.

Add Module

Azure automation works using Modules. We can download modules using the Modules menu (under shared resources).

  • Click on Modules -> Browse gallery.
  • Download the following modules.
  • Az.Accounts – For Azure authentication
  • Az.recovery services – For managing Azure backups
  • Az.Resources – For managing Azure resources

Update Azure Modules

After downloading all the above Azure AZ ARM modules, I will click on the Update Azure Modules button located on the Modules page.

Create Runbook

Runbooks is where everything happens, runbooks are scripts where we copy or write our scripts into.

I will create a new runbook from the Runbooks menu. In my case, I am using a PowerShell Module.

After creating the runbook, I will edit it using the edit menu.

In the edit page, I will use the code below.

Note: Enter the values that match your environment in the code under:


Use the Test pane to test the code.


When you are ready, click on Publish and set up the schedule.

Related Articles

Success! You're on the list.