Over the course of time, there have been a number of ways to duplicate/replicate an Azure Virtual Machines. Some methods were time consuming, required an understanding of PowerShell or backup services, would require some form of reboot and would generally incur some kind of cost. However, I stumbled across a method a few days ago which allows you to take a snapshot of the virtual disk and then build a new disk with the snapshot. The result being a duplicated machine, without having to power down the machine or using a backup/restore method. All of which doesnt require an understanding of PowerShell or Backup services and doesnt incur much of a cost.
Please note that this method will require the use of Managed Disks!
Here are the steps that I took:
While this is a good way to duplicate a machine to do some testing on, or to make a repeatable server for demos, there are some obvious limitations. The one being that you have to do each server/disk one by one, which makes it a long process for large environments. Although, there are probably options to script this to make it quicker, it arguable that you might as well just right your whole environment as a script (Using JSON and DSC) and take the infrastructure as code approach. Also, from the looks of it, you can only apply a snapshot to a managed disk, and not a VHD file that is located in a storage account, further to this, you can only take a snapshot from a managed disk, so if you are not using managed disks to begin with then this method will not work for you.
While Storage Accounts do have snapshot functionality, there isn’t a way to restore this onto a new disk (even within the storage account itself), the snapshots can only be promoted to the original BLOB which allows for rollback of the original disk/file.
I hope this guide has been useful! This feature has helped me build repeatable servers for testing and demos which has saved me a lot of time and effort, rather than building and configuring a server from scratch!
Thanks for reading!