Cloning Azure VMs
Tags: azure, azurevm
Published: 2022-12-01 23:46:27

_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](https://dev.to/icebeam7/azure-advent-calendar-o60)** 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9uw1tea0n44wptkrlpfo.png)


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s08gul03vnaa8nn0gsi3.png)


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


![Creating a disk snapshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ikwngazp1kk6cpls2li.png)


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qvwi08gpuh1u4022lp7.png)


_(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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6p916h0udfli4o4aur2.png)


_(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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zsczrr7rmhcev7fk73k0.png)


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e00rd1mecfp4vqxse2ca.png)


**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)](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r13ilqrd0ev0v2phwo10.png)

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](https://dev.to/icebeam7/net-maui-advent-calendar-48d0)**. You can also follow the conversation on Twitter with the hashtag **[#AzureAdvent](https://twitter.com/hashtag/AzureAdvent)** and in the Learning Azure Community on Facebook.

Thanks for reading. Until next time!

Luis