Follow @StolarekMarcin

Nearly a month ago I posted an article discussing the topic of VMs resize in Azure in general. No more than a few days after I’d published it I tried to resize one of my Standard_DS1 VMs to cheaper Basic_A1. Nothing difficult in azure-cli?

$ az vm deallocate -n myVM -g myGroup >& /dev/null $ az vm resize -n myVM -g my myGroup --size Basic_A1 >& /dev/null $ az vm start -n myVM -g myVM Deployment failed. Correlation ID: 0898f685-85f7-4ea6-9dbd-3ea53fab41ae. Requested operation cannot be performed because storage account type 'Premium_LRS' is not supported for VM size 'Basic_A1'.

Uuups… Looks like lowering the price didn’t work for me:), because cheaper hardrware profile/VM size doesn’t support the Premium_LRS(default) SKU of the storage account used by my VM. The question then arises:

How can I resize VM to the size that doesn’t support my storage account SKU?

Fortunately, it’s quite easy to adjust storage account type used by my managed VM[1]. When the VM is undeployed and it’s usually the case if you are resizing from Standard_DS1(default) to Basic tier (from my experience Basic tier was never available on the cluster used for the VM I had created as Standard_DS1). We can update all VM drives with the following azure-cli one liner:

$az vm show --name myVM -g myGroup --query storageProfile.[dataDisks[].managedDisk.id,osDisk.managedDisk.id] -o tsv | xargs -I ID -n1 az disk update --ids ID --sku Standard_LRS



and then start our VM:



$az vm start -n myVM -g myVM

Initially when met this issue I thought that there was no one step way to do that. My approach in a few points was:

1) Create a snapshot from the disk of running VM

2) Create a disk from this snapshot on Standard_LRS SKU to have it compatible with Basic tier

3) Delete old VM

4) Create new VM with the NIC from the old one and the disk from point 2)

5) Deallocate newly created VM (yes.. It will probably be on the cluster that doesn’t support Basic tier, since the snapshot was from Standard_DS VM)

6) Resize new VM to Basic_A1

7) Start the VM

I wrote a script implementing this overcomplicated (with the points 5-7 being there only because I didn’t think about selecting size in point 4) approach [2] – not really useful, because there is a simpler way to do that. However, it was quite teachy.

[1] https://funinit.wordpress.com/2017/12/18/managed-vs-unmanaged-vm-disks-in-ms-azure/

[2] https://gist.github.com/cinek810/df99794a9c0035d99e36e8d36ae99d47