DEV Community

Cover image for Cloning Azure VMs
Luis Beltran
Luis Beltran

Posted on

Cloning Azure VMs

This publication is part of the Azure Advent Calendar 2022, an initiative led by Héctor Pérez and Luis Beltrán. Check this link for more interesting Azure articles posted by community members.

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!

An Azure Virtual Machine

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.

Selecting the Azure VM OS Disk

Step 2. Create a disk snapshot by clicking on the Create snapshot button.

Creating a disk snapshot

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.

Preparing the snapshot

(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.

Creating a 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.

Managed disk options

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.

Creating a virtual machine

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).

The new virtual machine (clone)

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. Now my students can access them and we can work during the semester :)

I hope this publication has been useful to you, don't forget to share it, maybe it will help someone else =)

Remember to follow the rest of the interesting publications of the Azure Advent Calendar 2022. You can also follow the conversation on Twitter with the hashtag #AzureAdvent and in the Learning Azure Community on Facebook.

Thanks for reading. Until next time!


Top comments (2)

kgiannakakis profile image
Kostas Giannakakis

Very helpful information. Please note that, when creating the managed disk, Azure preselects a size of 1024GB. This is far more from what you probably need and very expensive. It would be difficult to later reduce the size, so pay attention to this step.

robertw profile image

Thanks! Worked like a charm!