Azure VM Snapshots
You can take a snapshot anytime, but if you’re taking snapshots while the VM is running, keep these things in mind:
When the VM is running, data is still being streamed to the disks. As a result, snapshots of a running VM might contain partial operations that were in flight. If there are several disks involved in a VM, snapshots of different disks might have occurred at different times.
An option to create consistent backups with snapshot is to shut down the VM and take snapshots of each disk.
Snapshots exist independently of the source disk and can only be used to create new managed disks. You can’t use them to change the state of an existing disk.
However, unlike traditional snapshots, Azure snapshots can create new VMs, which is useful for testing and one-off backups.
Best practices in mind when creating and using Azure snapshots:
Where possible, create the Azure snapshot when the machine is powered off — it makes the disk more consistent. If the VM is not powered off already, it will be when the snapshot is taken.
Don’t keep snapshots for longer than needed; they cost money and can negatively affect performance.
Don’t use snapshots as a long-term backup strategy. Instead, use Azure Backup — it doesn’t require human interaction, which reduces human error and other risks.
Use Cases of Azure snapshot:
Custom backup and Disaster recovery
Overwrite OS disks without recreating a VM
Troubleshoot VM issues
Steps to create snapshot of a managed data disk present in an Azure Virtual Machine
1. Go to azure portal and search for snapshot.
2. Click on create and select the subscription and RG (where you want to store the snapshot).
3. Give any unique name to your snapshot.
4. Select the region in which your azure virtual machine and data disk resides in. Along with this, select the snapshot type: Full or Incremental. Incremental Snapshot will store only the changes that were new as compared to last snapshot.
5. Now select the source type, source subscription, source disk and security type (you can’t update the options which are zoned out as shown below.
6. If you choose the incremental snapshot, Storage type will be set automatically based on the source disk.
7. In the encryption tab, select encryption type.
8. In the networking tab, choose the type of access you want to enable for snapshot.
9. Go to advanced section and click on Data access authentication mode.
10. Add tags if needed and click on review and create.
Difference while taking snapshot of OS Disk and Data Disk of an Azure VM:
- When we take snapshot of an OS Disk, then we can create a disk from it, we can create a VM Image Version or we can copy that snapshot.
And, when we create a disk out of snapshot taken from OS Disk of VM, then we can again create a VM using it. So this is how snapshots of OS Disk can be used for infra re-use or to create multiple virtual machines.
2. When we take snapshot of a Data Disk, then we can copy the snapshot and we can create a disk out of it.
But when we create a disk from the snapshot of a data disk of virtual machine, then we can again create a snapshot out of it and not the VM. Hence snapshot of data disk can be used as backup option to store application related data.