Azure VM snapshots are a great way to capture the state of your virtual machine at a particular point in time. This feature allows you to easily recover from data loss or system failures.
A VM snapshot is essentially a copy of the virtual machine's state, including the operating system, files, and configurations. It's like taking a picture of your VM's current state, which you can then use to restore it to that exact point in the future.
Azure Managed Disks are the recommended storage option for Azure VMs, as they provide a more scalable and durable storage solution compared to unmanaged disks. This means you can store your VM's data in a more reliable and efficient way.
With Azure Managed Disks, you can easily create, manage, and delete snapshots of your VM's state, making it a convenient and efficient way to work with your virtual machines.
Creating a VM Snapshot
Creating a VM snapshot in Azure is a straightforward process that can be completed in a few steps. Log in to the Azure portal using a valid credential that has a valid subscription.
To create a snapshot, choose All Services → Compute → Snapshots and click Create snapshot. In the instance details section, provide a name for the snapshot resource.
The region where this snapshot resource should reside can be chosen from the available options. You can choose any one of two options for the snapshot type: Full or Incremental.
- Full makes a complete read-only copy of the selected disk.
- Incremental makes a partial copy of the disk based on the difference between the last snapshot.
Choose the source disk, which is the name of the managed disk you want to take a snapshot of. In this case, we are taking the snapshot of the managed disk “VembuDemoManagedDisk” created in the above steps.
The storage disk selection allows you to choose the storage type, which can be any of three types: Standard HDD, Premium HDD, or Zone redundant. Here, we are choosing Standard HDD.
Click Next to configure the encryption option for the snapshot. You can choose any of the three options listed, but we are choosing the default option “Encryption at rest with a platform managed key”.
Understanding VM Snapshots
Azure snapshots are a backup tool to ensure administrators have a good copy of virtual machine disks if needed. They can also be cloned into additional VMs.
Snapshots are created using PowerShell or Azure CLI. It's a good idea to create snapshots when the machine is powered off, as this makes the disk more consistent.
A snapshot remains accessible for up to five days, depending on the user's configured snapshot retention settings.
Snapshots are not meant to be used as a long-term backup strategy. Instead, use Azure Backup, which doesn't require human interaction and reduces human error and other risks.
Azure snapshots can be used for various purposes, including custom backup, restore and rebuild a VM, disaster recovery, overwrite OS disks without recreating a VM, make a copy of a VM, and troubleshoot VM issues.
Here are some best practices to keep in mind when creating and using Azure snapshots:
- Create the Azure snapshot when the machine is powered off to make the disk more consistent.
- Don't keep snapshots for longer than needed, as they cost money and can negatively affect performance.
- Use Azure Backup instead of snapshots as a long-term backup strategy.
Backup
Azure Backup is a great tool for creating point-in-time copies of your VM, which is more efficient than manual snapshots.
You can use Azure Backup to restore the entire VM, which isn't automatically available with Azure Virtual Machines.
Azure Backup operates while the VM is still running, so you don't have to power down every 15 minutes to take a consistent snapshot.
To recover using a snapshot, you'll need to create a new disk from the snapshot, which can be done in the Azure portal.
You can then deploy a new VM using the managed disk as the OS disk, or attach the disk as a data disk to an existing VM.
Managed Disks
Managed Disks are a crucial part of Azure VM snapshotting. They provide high availability and durability, with an availability of 99.999% in all regions. Azure maintains three replicas of each managed disk in three different regions, ensuring data availability and high tolerance against failures.
Managed disks can be used to create up to 50,000 disks in one subscription per region, allowing for 1,000 VMs in one subscription. Each managed disk can be encrypted using Server Side Encryption (SSE) or Azure Disk Encryption (ADE).
Azure Disk Backup service can be used to create a backup policy and schedule automated snapshots of each disk regularly. This provides an additional layer of protection for your managed disks.
Remove
To remove a managed disk, you'll need to delete it from the Azure Portal or using the Azure CLI. From the Azure Portal, navigate to the disk you want to delete and click the "Delete" button. Be cautious, as this action is permanent and cannot be undone.
To delete a managed disk using the Azure CLI, you can use the az disk delete command. For example, to delete a disk with the name "myDisk", you would run the command: az disk delete --resource-group myResourceGroup --name myDisk --yes.
If you're deleting a disk that was associated with a VM, you may also need to delete the snapshot created from that disk. To delete a snapshot, navigate to the snapshot blade in the Azure Portal and click the "Delete" button, or use the az snapshot delete command in the Azure CLI.
Here are the basic steps to delete a managed disk using the Azure CLI:
- Run the az disk delete command with the --resource-group and --name parameters to specify the disk to delete.
- Use the --yes parameter to confirm the deletion.
- Verify the deletion by checking the Azure Portal or using the az disk show command.
Managed Disks
Managed Disks offer high availability and durability, with an availability of 99.999% in all regions. Azure maintains three replicas of each managed disk in three different regions, ensuring data availability and high tolerance against failures.
You can create up to 50,000 managed disks in one subscription per region, allowing you to create 1,000 VMs in one subscription. This makes it easy to scale your infrastructure as needed.
Managed disks can be encrypted while creating, meeting organizational security and compliance commitments. You can choose from two different kinds of encryption: Server Side Encryption (SSE) and Azure Disk Encryption (ADE).
Here are the two encryption options:
Managed disks also offer automated snapshots, which can be used for backup or to create a managed disk from a snapshot. You can use the Get-AzSnapshot command to list the snapshots within a subscription.
To create a managed disk, you can use the Azure portal or Azure PowerShell. Using Azure PowerShell, you can create a new VM by attaching a specialized managed disk or its snapshot as the OS disk.
Sources
- https://www.jorgebernhardt.com/how-to-create-snapshots-for-azure-managed-disks/
- https://www.techtarget.com/searchcloudcomputing/tip/How-to-create-snapshots-for-Azure-VMs-and-managed-disks
- https://stackoverflow.com/questions/77158667/azure-vm-backup-taking-longer-than-expected
- https://www.bdrsuite.com/blog/microsoft-azure-managed-disks-and-snapshots/
- https://learn.microsoft.com/en-us/azure/virtual-machines/snapshot-copy-managed-disk
Featured Images: pexels.com