StarWind is a hyperconverged (HCI) vendor with focus on Enterprise ROBO, SMB & Edge

Automating Disk Snapshots using Azure Runbook

  • October 8, 2019
  • 5 min read
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.
IT Production Manager. Nicolas is primarily focused on Microsoft technologies, he is a Microsoft MVP in Cloud and Datacenter Management.

Automating Disk Snapshots


There are two ways to backup your Azure Virtual Machines: First method is using the Azure Backup service in order to backup Virtual Machine periodically based on a backup policy. The Azure Backup service backs up data from on-premises machines, and Azure VMs. Data can be backed up and recovered at a granular level. Second method is creating VM disk snapshots in order to backup a disk manually. It is great when you try to backup a VM for which Azure Backup can not be used.

In this article, I will explain the second option in order to automate the process of creating disk snapshots using PowerShell.

Creating Azure Runbook

In this article, I will create daily snapshots of the disks which have associated tagname ‘Snapshot’ with tagvalue ‘True’. First, we have to create the tag on the Virtual Machines that must be snapshotted. Open the Azure Portal, navigate to the Virtual Machine blade and ‘Tags’:

Creating Azure Runbook

Now, we can create the Runbook from the Azure Automation blade. If you don’t already have an existing automation account, then create a new one.

Click ‘+ Create a runbook


And enter the following information:

  • Name: It is a friendly name for the Runbook
  • Runbook Type: Select PowerShell in this case, but you can select another type if needed
  • Description: it is optional, but you can describe the goal of this runbook

Runbook name

The runbook is created, but before going deeper, we must update the modules. Go to ‘Modules gallery’ and search for ‘AzureRM.Resource’ which is a module we need in the runbook.

Une image contenant capture d’écran Description générée automatiquement

In order to import the module, click ‘Import


Before validating the wizard, select the checkbox in order to update all the modules.

Agree to update all the modules

Go back to the ‘Modules’ blade and confirm that the module is available


Now, edit the runbook and copy/paste the following PowerShell code.

Publish the Runbook when everything is ok, and then go back to the Azure Automation Account and select Schedules. Click on ‘Link to schedule’.


Link to schedule

You can confirm the schedule is created

Schedule is created

You just need to wait until the runbook start, then a snapshot will be created

Create disk snapshot


Thanks to Azure Automation, you can very easily and quickly deploy a Runbook to backup a Virtual Machine. You can also automate tasks that you performed manually.

Thanks for reading!

Found Nicolas’s article helpful? Looking for a reliable, high-performance, and cost-effective shared storage solution for your production cluster?
Dmytro Malynka
Dmytro Malynka StarWind Virtual SAN Product Manager
We’ve got you covered! StarWind Virtual SAN (VSAN) is specifically designed to provide highly-available shared storage for Hyper-V, vSphere, and KVM clusters. With StarWind VSAN, simplicity is key: utilize the local disks of your hypervisor hosts and create shared HA storage for your VMs. Interested in learning more? Book a short StarWind VSAN demo now and see it in action!