Upgrade those VMs to Premium Storage!

Let's say you have a production VM running in Azure. That's pretty common these days and you find yourself monitoring them and thinking, gosh, I should be able to get more umph out of this thing. SSD the OS disk (and the data disks if needed) and life will get infinitely better! In fact, I've seen numerous instances where customers can actually downgrade the VM series a step or two and still see the same performance simply by moving to SSD. Why? Spinning disks are so last year. Here's some easy tricks to get you going using nothing by magical commands.

First, login to AzureRM:

Add-AzureRMAccount
Select-AzureRMSubscription -SubscriptionID <...>

Export the Azure ARM Template for the Resource Group inside the portal and click Download. This will give you a ZIP file that we'll edit here in a bit. We only care about the VM so other things will stay the same. You could also use Export-AzureRMResourceGroup but it isn't quite up to par yet and only gives you the JSON, not a shiny PS command you can just run. Your call.
Now that you've exported it, proceed.


Stop-AzureRMVM -Name $vmName -ResourceGroupName $RGName -Force
Remove-AzureRMVM -Name $vmName -ResourceGroupName $RGName -Verbose

Now, you need to create you a premium storage account to hold the blobs and a container:

New-AzureRmStorageAccount -ResourceGroupName $RGName -Name $NewStorageAccountName -Type Premium_LRS -Location "Central US" -Verbose
$ctx = New-AzureStorageContext -StorageAccountName $NewStorageAccountName -StorageAccountKey "...Key1 from your new Storage Account"
New-AzureStorageContainer "vhds" -Permission Off -Context $ctx

Next, you will AzCopy the VHD(s) from the old container to the new container. If you don't have AzCopy, get it here (Update 4-7-16: Adam reminds me there is in fact some PowerShell to do this, see * below).

From an AzCopy command prompt (not your PowerShell prompt cause it isn't in the PATH):
AzCopy /Source:https://sourceaccount.blob.core.windows.net/mycontainer1 /Dest:https://destaccount.blob.core.windows.net/mycontainer2 /SourceKey:key1fromsource /DestKey:key1fromdestination /Pattern:filename.vhd
You could also do *.vhd if that container only has your 1 VM's VHD(s) in it as the pattern.

Once that's done, make a quick edit to your exported template (it's just JSON, don't be scared):
{ "hardwareProfile": { "vmSize": "Standard_DSx" { "osDisk": { "osType": "Windows", "encryptionSettings": null, "name": "vm-name", "vhd": { "uri": "https://premiumstorageaccount.blob.core.windows.net/vhds/vmname-osdisk.vhd" } (Where "Standard_DSx" is the size you want and the URI is the full path to your OS disk...if you have more disks, they will be listed there too for changing.)

Now, you're ready to deploy. Run the PowerShell command that came with your template download and poof, migrated!

Don't forget to delete your old VHD from the old container to clean things up (and delete the storage account if it's now empty).

*From Adam (with big thanks!) - there is a way to perform the copy operation entirely within PowerShell without having to use AzCopy. The command is "Start-AzureStorageBlobCopy" and more details can be found here.