Resize Azure ARM virtual machine with PowerShell

I recently worked on a project where we needed to resize VMs in Azure to be able to scale up or down during different periods of the month. Since these VMs where created using Azure Resource Manager (ARM) we needed to use the new AzureRM PowerShell cmdlets. So naturally I tried Set-AzureRmVMSize, but to my surprise there was no such cmdlet. It turns out that it’s actually not supposed to work with the current version of AzureRM modules:

But then I found the following blog post by Igor Pagliai:

So with just a little modification of the example he provides its really quite simple to achieve.

Note that it’s only necessary to stop the VM if you're also changing SKU when doing the resize, read more about that on Igor's post above. It also describes what you need to think about regarding storage etc. Note that if changing size within the same SKU the VM will still reboot.

So below is a simple script to resize a VM with the AzureRM modules.


$ResourceGroupName = "CMLAB"

$VMName = "2007CMCEN"

$NewVMSize = "Standard_A5"


$vm = Get-AzureRmVM -ResourceGroupName $ResourceGroupName -Name $VMName

$vm.HardwareProfile.vmSize = $NewVMSize

Update-AzureRmVM -ResourceGroupName $ResourceGroupName -VM $vm