In this post I’m going to cover migrating Azure Virtual Machines to Premium Storage.
Converting your current Azure VMs from Standard Storage to Premium Storage cannot be done from the portal. The process is a mix of scripting and manual steps, although it can be fully scripted if need be. In short you have to make a new Premium Storage account, copy the blobs of the VHDs you need and then recreate the virtual machines using the copied VHDs. In this example I’m migrating a VM disk to create a single new VM, not an image that will be used to create multiple VMs.
Preparation
Make sure Premium Storage is available in the Azure region you want to use and also which types of VMs you can use with Premium Storage, you need *S type VMs like DS and GS. Take note of the extra cost involved using Premium storage and the performance characteristics of the different drives and VMs here.
Step 1
You have to shut down your VMs to migrate them and it takes a while so be prepared for down time or use availability sets. You will need the URI of each drive attached to your VM in order to copy them. In the new portal you can see the URI when you click on the disks of the VM. In the old portal there is a separate tab for disks under the virtual machines section.
Step 2
In the portal create your new Premium Storage account in the desired region and create a blob container to store the hard disks. Make sure you choose Premium Storage.
Step 3
Next you have to copy the VHD blobs to the new storage account, you can use PowerShell or 3rd party tools with a GUI like CloudBerry.
$sourcevhd = "https://source_account/vhds/MyDisk.vhd" $srcContext = New-AzureStorageContext –StorageAccountName your_source_account -StorageAccountKey your_source_account_key $dstContext = New-AzureStorageContext –StorageAccountName your_dest_account -StorageAccountKey your_dest_account_key Start-AzureStorageBlobCopy -srcUri $sourcevhd -SrcContext $srcContext -DestContainer "vhds" -DestBlob "NewDisk.vhd" -DestContext $dstContext
This step can take a while depending on the size of the VHD. Repeat for every data disk attached to your VM.
Step 4
Create a new VHD from the blob you just copied to the Premium Storage account. You can use the old portal if you prefer a GUI
or PowerShell.
Add-AzureDisk -DiskName "NewDiskName" -MediaLocation "https://your_storage_account/vhds/NewDisk.vhd" -Label "New OS Disk" -OS "Windows"
Step 5
Create a new VM using the disk you prepared in the previous step. You can use PowerShell.
$OSDisk = Get-AzureDisk –DiskName "NewDiskName" $vm = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -DiskName $OSDisk.DiskName New-AzureVM -ServiceName $serviceName –VM $vm
Note I used DiskName not ImageName in creating the VM. You can also use the old portal but choose My Disks as the source of the VM:
The steps above copied the OS disk of a VM, if you have data disks attached to the VM you have to repeat the process to copy the data disks as well. Use the Add-AzureDataDisk cmdlet to attach the data disks to your new VM.
If you want to create multiple VMs create an image instead of a disk using Add-AzureVMImage and point it to a generalised VHD.