Reputation: 4946
I try to clone an existing VM. Requirements:
So at first I captured my existing VM. Now here are my 4 tries which didn't work:
New-AzureVM : ConflictError: A disk with name xxxxx is currently in use by virtual
machine xxx running within hosted service xxx, deployment xxx.
Yeah, of course the disk is in use by a VM; I thought this script deals with this fact and copies both VM and vhd?!So I'm out of ideas how to clone a VM with my requirements. Hope you can help.
Upvotes: 0
Views: 311
Reputation: 2206
If you know Azure PS this can be done in these steps.
Step 1. Move all the vhds to your newstorge account which you have already done. great !
Step 2. convert the vhds to disk using Azure PS-
Add-AzureDisk -DiskName "YourVHDName" -MediaLocation "https://NewStorageAccountName.blob.core.windows.net/vhds/YourVHDName.vhd" -os "Windows"
(for os disk )
Add-AzureDisk -DiskName "YourVHDName"
-MediaLocation "https://NewStorageAccountName.blob.core.windows.net/vhds/YourVHDName.vhd"
Step 3. Most Important spin vm using OS disk-
Set-AzureSubscription -SubscriptionId "YourSubscriptionId"-CurrentStorageAccountName "NewStorageAccount"
$vm=New-AzureVMConfig -DiskName "YourVHDName" -InstanceSize "YourInstanceSize" -Name "YourVMName"
New-AzureVM -Location "YourLocation" -ServiceName "YourNewService" -VNetName "YourNewvNet" -VM $vm -verbose
Upvotes: 1