Edit

Create virtual machine restore points using Azure CLI

You can protect your data and guard against extended downtime by creating VM restore points at regular intervals. You can create VM restore points, and exclude disks while creating the restore point, using Azure CLI. Azure CLI is used to create and manage Azure resources using command line or scripts. Alternatively, you can create VM restore points using the Azure portal or using PowerShell.

The az restore-point module is used to create and manage restore points from the command line or in scripts.

In this tutorial, you learn how to:

Prerequisites

Step 1: Create a VM restore point collection

Use the az restore-point collection create command to create a VM restore point collection, as shown below:

az restore-point collection create --location "norwayeast" --source-id "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/virtualMachines/ExampleVM" --tags myTag1="tagValue1" --resource-group "ExampleRg" --collection-name "ExampleRpc" 

Create a VM restore point collection with instant access

Instant Access is optional and applies only to VMs with Premium SSD v2 or Ultra Disks as data disks. It supports both application-consistent and multi-disk crash-consistent (in preview) restore points. When you enable Instant Access on the restore point collection, disk restoration can begin immediately from the restore point without waiting for full hydration. This feature significantly reduces RTOs. To learn more, see Instant Access.

az restore-point collection create --location "norwayeast" --source-id "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/virtualMachines/ExampleVM" --tags myTag1="tagValue1" --resource-group "ExampleRg" --collection-name "ExampleRpc" --instant-access true

Step 2: Create a VM restore point

Create a VM restore point with the az restore-point create command as follows:

az restore-point create --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

To create a crash-consistent restore point, set --consistency-mode to CrashConsistent.

Create a VM restore point with specific instant access duration

Create a VM restore point with the az restore-point create command as follows:

az restore-point create --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp" --instant-access-duration "120"

Note: Instant Access duration is an optional parameter. Its an integer property set on each restore point. Specifies how long Instant Access remains active, in minutes. Valid range: 60–300 minutes. Default: 300 (5 hours).

For a multi-disk crash-consistent restore point with Instant Access (in preview), use the Instant Access-enabled collection from step 1 and specify both the consistency mode and duration:

az restore-point create --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleCrashConsistentRp" --consistency-mode CrashConsistent --instant-access-duration 120

Exclude disks when creating a restore point

Exclude the disks that you do not want to be a part of the restore point with the --exclude-disks parameter, as follows:

az restore-point create --exclude-disks "/subscriptions/{subscription-id}/resourceGroups/ExampleRg/providers/Microsoft.Compute/disks/ExampleDisk1" --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

Step 3: Track the status of the VM restore point creation

Use the az restore-point show command to track the progress of the VM restore point creation.

az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp"

If the restore point collection has Instant Access enabled, check instantAccessState to validate the consolidated access state across all disk restore points within the restore point.

az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp" --instance-view --query "instanceView.statuses[1]" -o tsv

A value of InstantAccess or AvailableWithInstantAccess means the restore point is ready for fast disk restoration.

Restore a VM from VM restore point

To restore a VM from a VM restore point, first restore individual disks from each disk restore point. You can also use the ARM template to restore a full VM along with all the disks.

# Create Disks from disk restore points 
$osDiskRestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpc" --name "ExampleRp" --query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk1RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
$dataDisk2RestorePoint = az restore-point show --resource-group "ExampleRg" --collection-name "ExampleRpcTarget" --name "ExampleRpTarget" –query "sourceMetadata.storageProfile.dataDisks[0].diskRestorePoint.id"
 
az disk create --resource-group “ExampleRg” --name “ExampleOSDisk” --sku Premium_LRS --size-gb 128 --source $osDiskRestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk1RestorePoint

az disk create --resource-group “ExampleRg” --name “ExampleDataDisk1” --sku Premium_LRS --size-gb 128 --source $dataDisk2RestorePoint

Once you have created the disks, create a new VM and attach these restored disks to the newly created VM.

Disable instant access for future restore points

Update a VM restore point collection with the az restore-point collection update command as follows:

az restore-point collection update -g MyResourceGroup --collection-name ExampleRpc --tags myTag1="tagValue1" --instant-access false

Next steps

Learn more about Backup and restore options for virtual machines in Azure.
Learn more about Instant Access restore points.