Migrating Virtual Machine Storage from Standard to Premium in Azure Classic


In Azure you can choose between 3 different types of storage for your virtual machines.

These 3 different types are:

If you need more IOPs or Throughput than the above will provide you can attached multiple disks to a VM and bind them together using storage spaces.

Also bear in mind your VM size dictates if you can you premium storage and also what IOPs rate you will be capped at regardless of how many disks you stripe together.

Now having got all of that out the way as an introduction. You can migrate your Virtual Machines from standard to standard managed disks or premium to premium managed disks but the jump in between is not so fun.

In this particular scenario I had a VM on Azure Classic using Standard Storage and I needed to migrate it to Premium Storage for better performance. To do this I wrote a small powershell scripts that will copy the VHD from one storage account to the next.

Ensure that the VM is powered off in the Azure portal before running this script. Also, remember that you need the Azure classic connection via powershell so you’ll be looking to connecting using Add-AzureAccount or similar.

Here is the powershell script I used:

[cc lang=“powershell”]

#List out the VHD’s that need to be copied just for reference #VHD 1 P0 – VM_VHD1.vhd #VHD 2 P1 - VM_VHD2.vhd

#To login to the Azure Classic Portal #login - Add-AzureAccount Add-AzureAccount

# VHD blob to copy # $blobName = “VM_VHD1.vhd” $blobName1 = “VM_VHD2.vhd”

# Source Storage Account Information # $sourceStorageAccountName = “” $sourceKey = “” $sourceContext = New-AzureStorageContext –StorageAccountName $sourceStorageAccountName -StorageAccountKey $sourceKey $sourceContainer = “"

# Destination Storage Account Information # $destinationStorageAccountName = “" $destinationKey = "" $destinationContext = New-AzureStorageContext –StorageAccountName $destinationStorageAccountName -StorageAccountKey $destinationKey

# Create the destination container # $destinationContainerName = “" New-AzureStorageContainer -Name $destinationContainerName -Context $destinationContext#

# Copy the blob # $blobCopy = Start-AzureStorageBlobCopy -DestContainer $destinationContainerName -DestContext $destinationContext -SrcBlob $blobName -Context $sourceContext -SrcContainer $sourceContainer $blobCopy1 = Start-AzureStorageBlobCopy -DestContainer $destinationContainerName -DestContext $destinationContext -SrcBlob $blobName1 -Context $sourceContext -SrcContainer $sourceContainer

#Get Status of the Job as it copies while(($blobCopy Get-AzureStorageBlobCopyState).Status -eq “Pending”) { Start-Sleep -s 10 $blobCopy Get-AzureStorageBlobCopyState $blobCopy1 Get-AzureStorageBlobCopyState }
#To Cancel a job if you decided you have waited too long #$blobCopy1 Stop-AzureStorageBlobCopy #$blobCopy2 Stop-AzureStorageBlobCopy


A few notes:

To get your storage key you go here:

The copy process does take some time so be patient.

About Me

Photo of Leee Jeffries

I'm an IT professional with over 15 years of experience in the IT industry, I've worked in many fields in my career. This blog is to share my experience, tips and tricks.