Organizations frequently use virtual machine snapshots on premises in case they need to revert their systems back...
to a previous state, but the process works slightly differently on Microsoft Azure. Unlike on premises, there isn't a one-step option to take a snapshot of an entire VM state in Azure.
Disk snapshots on Azure VMs must be done individually for each virtual disk connected to a virtual machine. However, admins can still use Azure snapshots in a number of scenarios, including for custom backups, point-in-time restore operations and disaster recovery.
Azure Managed Disk snapshots, which require VMs configured with managed disks, is the default disk configuration for new VMs in Azure.
Unmanaged disks introduce administrative overhead that includes building and maintaining additional storage accounts for virtual disks. Also, the snapshot process can only be managed from the command line. For these reasons, Azure Managed Disk provides the best experience to create and restore snapshots.
You can use the Azure Portal to create a managed disk snapshot. First, navigate to the VM resource, select the disk that you want to back up and click Create snapshot, as shown in Figure 1.
You can also search for the snapshot resource in the Azure Portal to start the process. You'll be prompted to enter the server resource and disk you want to snapshot, as shown in Figure 2.
Azure Managed Disk snapshots must be done on a per-disk basis, as there's no way to snapshot all the disks at once. This has data corruption implications for software RAID and storage pools configured across multiple disks from within the VM's operating system. To ensure snapshot consistency across all the disks attached to a VM, you should turn the machine off before you take the snapshots.
Azure snapshots consume storage space and can affect your costs, so be mindful of how often you take them. If you take multiple snapshots of the same disk, they are full snapshots, not incremental, and those costs can add up quickly.
PowerShell and the Azure command-line interface (CLI) can also be used to perform disk snapshots. These tools are useful if you want to automate the process of snapshotting your VM disks.
The Azure CLI commands to invoke a snapshot of the OS disk for a VM named SERVER1 are shown in Figure 3.
The az snapshot create command requires the source ID for the disk you want to snapshot, as shown in Figure 3. The az vm show command is used to capture the disk id in a variable, and the next command runs az snapshot create to initiate the snapshot.
If you plan to do this frequently, you might want to use Azure Backup instead. You can easily schedule full VM backups rather than run these commands for every disk attached to your VMs. To implement Azure VM backups, deploy a Recovery Services vault and configure a backup schedule.
Restore or rebuild VMs from Azure snapshots
You can use Azure Managed Disk snapshots to rebuild a VM or perform a point-in-time restore based on a previous snapshot.
First, create a new managed disk resource either in the Azure Portal or from the command line with PowerShell or the CLI. Search for the managed disk resource in the Azure Portal and provide the name of the OS disk snapshot for the VM you want to restore, as shown in Figure 4.
Navigate to the new managed disk resource after the build process is complete. As shown in Figure 5, you'll see a Create VM button in the properties of the disk resource that can be used to launch a new VM with all of the data from the snapshot intact.
Some IT teams use managed disk snapshots for disaster recovery. It's possible to use PowerShell or the Azure CLI to copy Azure snapshots from one region to another, but the process requires a fair amount of work. The administrative overhead with this approach can become unmanageable with a large number of servers each with their own individual set of attached virtual disks.
The Azure Site Recovery service provides a much better experience for VM disaster recovery. It natively supports VM replication from one region to another and captures all the data from both the OS and data disks. Azure Site Recovery replication can be enabled, monitored and controlled in the Azure Portal without any additional code.