Clone a VM

Glenn Maxwell 10,146 Reputation points
2020-09-07T04:59:48.697+00:00

Hi All
i have a azure VM lets say VM01, i want to clone this VM and rename it as VM02. is it possible to create clone from snapshot and is it possible to rename the VM from OS level to VM02 and can i run sysprep.

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
{count} votes

Accepted answer
  1. Manish Jha 236 Reputation points
    2020-09-12T12:12:01.753+00:00

    I may have misunderstood the question but if you want to clone the VM perform these steps

    1) Go to the Azure Portal and navigate to the Virtual Machine that you want to clone

    2) Navigate to the disk , click on the OS disk and then create a snapshot of the disk, repeat the same thing for the Data disk if any

    3) Now click on create resource and search for managed disks, fill in all the details and then under source type choose snapshot and then click on create the disk, and do the same thing for the data disk too
    24148-image.png

    4) Once the managed disk for the OS has been created, click on create VM and then when you navigate to the storage section, you can also add the Data disk and this VM would be a clone of the existing VM

    let me know if you run into any issue

    0 comments No comments

5 additional answers

Sort by: Newest
  1. Kyle Burkett 1 Reputation point
    2021-11-08T21:38:40.233+00:00

    This is #1 google result but it seems clearly to be missing steps for windows domain joined environment as Sergio points out last year...

    Here are links to what I will be referencing when I attempt it (if I do):

    https://serverfault.com/questions/749625/cloning-virtual-machine-on-azure-keeping-existing

    https://community.spiceworks.com/topic/2287385-clone-a-vm

    https://dejanstojanovic.net/powershell/2019/september/cloning-windows-virtual-machine-in-azure-without-having-to-stop-it/

    0 comments No comments

  2. Sumanth S Rao 1 Reputation point
    2021-04-16T13:31:06.503+00:00

    @Glenn Maxwell

    If you just want the metadata of the Virtual Machine to be cloned and not the contents of the disk, then you can try the export template option here.

    As soon as you open the Virtual Machine in the Azure portal, on the left pane, you must be seeing an option called "Export Template". You can click on the option, it will ask if you wanna save this template or deploy it. If you wanna do a one-time clone, you can go ahead and deploy, you can also edit the name of the resources associated with the old VM here and submit it.

    This will create a fresh VM with the same metadata and configuration(SSH keys, resource ID etc.,) as the old one.

    0 comments No comments

  3. Sergio Pacheco 21 Reputation points
    2020-10-08T20:36:37.947+00:00

    How do you clone an Azure VM without creating issues in a domain environment? @Manish Jha , won't the procedure above also create a duplicate windows guid? Following your process, we sysprepped the cloned VM using powershell (Set-AzVm -ResourceGroupName My-RG -Name TestSrv -Generalized) to generalize it but the VM we created wouldn't boot. When we checked the boot diagnostic it says it can't find the boot volume. We need to create copies of prod servers for our dev environment.

    4 people found this answer helpful.
    0 comments No comments

  4. Glenn Maxwell 10,146 Reputation points
    2020-09-09T05:23:02.87+00:00
    1. I have a server in US West, i have taken the snapshot of the primary partition of the server, from the snapshot i have created a managed disk, from managed disk when i am trying to create the VM in US East i am not able to since the option to select the region is grayed out. is it not possible to create VM across other region using managed disk.
    2. After creation of VM do i need to run sysprep at OS level or is it possible from the azure side.

    At the OS level is the below option OK.
    23278-sysprep.jpg

    0 comments No comments