Cloning Azure VMs
Cloning an Azure virtual machine is something I thought it was directly integrated (as in, one click/command and that’s it, but no, it involves several steps. However, it is not complicated, and in this post I will explain how to do it!
Step 1. Go to Azure portal, navigate to the virtual machine you want to clone. In the Disks section, click on its operating system disk.
Step 2. Create a disk snapshot by clicking on the Create snapshot button.
Step 3. Fill out the form (only the name is required). You can change other details such as the subscription, resource group, snapshot type if you want. Click on Review + Create, if there are no errors the resource will be successfully created.
(Repeat the above steps if the virtual machine contains data disks and you want to include them later in the clone VM as well)
Step 4. Now create a Managed Disk resource. Fill in the required information, and in the Source type field choose snapshot and select the corresponding subscription and snapshot that you just created. Click on Review + Create and if everything goes as expected, the you will get a new managed disk.
(Repeat step 4 for data disks you have previously cloned)
Step 5. Access to the details of this brand new resource and click on the Create VM button.
Step 6. Now fill in the requested data in the Basics section. Click on the Disks tab in order to add managed data disks in case you generated them too. Otherwise, simply proceed to click on Create + Review.
And that’s it! Once the resource is created, start the new virtual machine if it’s stopped, connect, and there you have it! An exact copy of the original resource (and independent of course, as it’s a new virtual machine with its own disk).
In my case, I first created a virtual machine and installed software such as Visual Studio 2022, Visual Studio Code, Anaconda, among others. Then, instead of repeating the same process (create new VMs, install manually the software in each of the new ones), I just followed the above 6-step process and voilá, I got exact copies (clones) of the virtual machines.