Steps to Delete and Recreate the VM:
Step 1: Delete the VM.
Step 2: Copy the VHD and spin-up a new VM with it.
Below are the steps to do it.
First we have to copy the VHD using AZcopy .
Using AZcopy :
Step 1 : Create a storage account in your desired Location, in a resource group
Download AzCopy here.
Use the following AzCopy command and run the command as shown below:
To copy entire disks in the storage account
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1 /DestKey:key2 /S
To copy only one disk, please give the name of the disk in pattern
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1 /DestKey:key2 /Pattern:abc.vhd
Where Source is
Go to https://portal.azure.com/ , Source storage account> Blobs > Container >Copy the URL
The source URL looks like : https://storageaccountname.blob.core.windows.net/mycontainer1
The grey highlighted part should go into the Source: section of the AzCopy command.
- SourceKey:
From the portal, select the source storage account > Access Keys
You can select either the primary or secondary and enter it into the SourceKey: section of AzCopy command.
- Destination:
From the portal again, select Destination Storage Account >Blobs ><>
The blob address followed by /mycontainer2 goes into the Destination: part of the AzCopy command.
Example : https://DestinationStorageAccountName.blob.core.windows.net/mycontainer2
- DestinationKey:
Select the destination storage account in the portalàAccess Keys àSelect either key1 or key2
Enter it into the DestinationKey: section of AzCopy command
Once the Azcopy command entered with all the required details. Go ahead and run the AzCopy command in the downloaded tool(Microsoft azure storage tools) >Run as an administrator>copy the command there.
Note: It will take few hours to complete the operation. You know the command is working when the transfer speed is changing.
Ensure that the transfer is done successfully by checking the Destination Storage account container in the Azure Portal.
Once the .VHD/disks are copied successfully to the destination storage account, then you have to recreate the VM by following the below steps :
You can use ARM Template instead of using PowerShell commands to Recreate a VM by following the below steps :
After the above activities are done, you can proceed to create a VM using the copied VHD. Open your Destination Subscription & login :
- From Portal, click on New> Template Deployment.
- Select template deployment and click on Create.
- Click on edit template as shown below
NOTE :This is only possible in ARM deployment model .
- Click on Quick start templates >search for ‘201-VM-specialized-vhd-existing-vnet’
- Accept terms and conditions and click ‘Purchase’ to start the VM deployment
- Post deployment VM will be running successful.