question

GlennMaxwell-2309 avatar image
1 Vote"
GlennMaxwell-2309 asked KyleAaronBurkett answered

Clone a VM

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-machinesazure-virtual-machines-networkingazure-virtual-machines-imagesazure-virtual-machines-migration
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@GlennMaxwell-2309 Any update on the issue?

If the suggested response helped you resolve your issue, do click on "Mark as Answer" and "Up-Vote" for the answer that helped you for benefit of the community.

Thanks.


0 Votes 0 ·
ManishJ avatar image
0 Votes"
ManishJ answered

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



image.png (34.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SumanthMarigowda-MSFT avatar image
1 Vote"
SumanthMarigowda-MSFT answered SumanthMarigowda-MSFT edited

@GlennMaxwell-2309 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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

GlennMaxwell-2309 avatar image
0 Votes"
GlennMaxwell-2309 answered
  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



sysprep.jpg (24.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SergioPacheco-6025 avatar image
3 Votes"
SergioPacheco-6025 answered SergioPacheco-6025 edited

How do you clone an Azure VM without creating issues in a domain environment? @Manishj, 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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SumanthSRao-9853 avatar image
0 Votes"
SumanthSRao-9853 answered

@GlennMaxwell-2309

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KyleAaronBurkett avatar image
0 Votes"
KyleAaronBurkett answered

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/

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.