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,101 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: Most helpful
  1. 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

  2. Sumarigo-MSFT 43,411 Reputation points Microsoft Employee
    2020-09-07T07:37:47.333+00:00

    @Glenn Maxwell Sysprep will remove the VM name within the VM so you should be able to recreate the VM from a snapshot, sysprep it and then use it as a image to create new ones. You want to rename from the Guest level right? Sysprep > create new VM > should help with renaming

    Note: How do I rename my VM Resource? This is different from renaming the guest OS compute name.
    The scenario of renaming the VM resource is unsupported and you have to delete the old resource and re-create the new VM resource with the new name.

    How to Rename an Azure VM

    -Is it possible to create clone from snapshot? Yes. Create a disk from the snapshot and create a VM from this disk.

    There is an MSDN thread with similar discussion, it's bit old however it can help you and provide more info on your scenario:

    Cloning Windows Virtual Machine in Azure

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    If you still find any difficulties or you need further assistance on this issue, kindly let us know.

    Hope this helps!

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

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

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