Sunday, January 1, 2017

Duplicating an Azure ARM VM

On Azure classic deployments, duplicating an Azure VM due to QA/R&D needs was easily done via the portal using the capture image option and later creating a VM from that image.
Unfortunately on ARM deployments this option is not available, so the course of action to create such a duplicate, is to use Powershell scripts.
In the below example, I deploy to an existing resource group and virtual network, but the scripts can be easily altered to create those as well if needed.

For the first step, I shutdown the VM I wanted to duplicate and copied its OS disk to a new storage/blob container (same blob container can be used, just need to rename the disk). To copy the disk I used Azure storage explorer.

And now for the Powershell scripts.