How to Quickly Clone a VM in Azure !

Abhimanyu

Cloud and DevOps Professional and previously a C# ASP.NET Developer with keen interest in system design and architecture. Currently involved in projects using AWS, Azure, Automation, Monitoring, REST APIs and DevOps. Email: abhimanyu12345@gmail.com / contactme@techmanyu.com

5 Responses

  1. Srinivas M says:

    Thanks for sharing the steps. This is such a basic requirement and should be available directly on portal. Azure should pick up fast.

  2. IvanD says:

    I don’t think this is going to work for the OS disk. Maybe they’ve changed something and now it doesn’t require you to delete the VM? It would be very nice if they did.

  3. rdai111 says:

    amazing, thank you! This works! The only thing worth pointing out is in the article you broke the script into two parts but there are variables in the first script that is used in the second.

    I ran the first script, then some how my powershell timed out or something so powershell “forgot” the variables in the first

    So I had to glue the two pieces together, comment out

    $disk = New-AzureRmDiskConfig -AccountType $storageType -Location $location -CreateOption Copy -SourceResourceId $snapshot.Id

    New-AzureRmDisk -Disk $disk -ResourceGroupName $resourceGroupName -DiskName $diskName

    and

    #(Optional Step) Add data disk to the configuration. Enter DataDisk Id
    $VirtualMachine = Add-AzureRmVMDataDisk -VM $VirtualMachine -Name $dataDiskName -ManagedDiskId -Lun “0” -CreateOption “Attach”

    since I don’t have an optional data disk, after that I ran the whole script again and it worked.

  4. Abhimanyu says:

    Agreed. Would have been better if I had combined the two sections of the scripts but wanted to breakdown the scripts so that they are easy to understand. Glad that it worked well for you.
    Thanks!

Leave a Reply