The other day i was trying to change the size of a Virtual Machine in Azure which is part of an availability set to the new more efficient V3 machines. What i noticed is that not all the VM Sizes were available. After some reading and research on the web i came across this article. The article explains the following:
“If your VM(s) are deployed using the Resource Manager (ARM) deployment model and you need to change to a size which requires different hardware then you can resize VMs by first stopping your VM, selecting a new VM size and then restarting the VM. If the VM you wish to resize is part of an availability set, then you must stop all VMs in the availability set before changing the size of any VM in the availability set. The reason all VMs in the availability set must be stopped before performing the resize operation to a size that requires different hardware is that all running VMs in the availability set must be using the same physical hardware cluster. Therefore, if a change of physical hardware cluster is required to change the VM size then all VMs must be first stopped and then restarted one-by-one to a different physical hardware clusters.”
So that’s logical when you think about it, the article mentions that: the same hardware cluster must be used to host all VMs in an availability set.
So let’s make this clear using powershell:
1 2 3 4 5 6 7 8 9 |
### Get you credentials, if you are using a Microsoft account you only can use Login-AzureRMAccunt, without -Credentials $Cred = Get-Credential -UserName "UserName" -Message "Please insert youre credentials" Login-AzureRMAccount -Credential $Cred ### Get the ResourceGroup where the availability set is part of $RGName = Get-AzureRmResourceGroup | Out-GridView -Title "Select Resourcegroup" -OutputMode Single ### Get the Availability set $AvSet = Get-AzureRmAvailabilitySet -ResourceGroupName $RGName.ResourceGroupName | Select Name | Out-GridView -Title "Select AvailabilitySet" -OutputMode Single ### Get available VM Sizes Get-AzureRmVMSize -ResourceGroupName $RGName.ResourceGroupName -AvailabilitySetName $AvSet.Name |
The output when only one VM in the availability set is in a “running” state:
So now lets stop the running VM:
1 2 3 4 5 6 |
### Get the running virtual machine(s) $VMs = Get-AzureRmVM -ResourceGroupName $RGName.ResourceGroupName -Status | Out-GridView -Title "Select VM's you want to edit the VmSize" -OutputMode Multiple ### Stop all the selected running VM's foreach ($VM in $VMs){ Stop-AzureRmVM -Name $vm.name -ResourceGroupName $RGName.ResourceGroupName -Force } |
Again run the Get available VM Sizes
1 2 |
### Get available VM Sizes Get-AzureRmVMSize -ResourceGroupName $RGName.ResourceGroupName -AvailabilitySetName $AvSet.Name |
The output cannot be captured on 1 screen:
So after shutting down (deallocated) the last VM in an availability set the adiotional VM Sizes are available.
1 2 3 4 5 6 7 8 |
### Select the new VM Size for the selected VMs $NewVMSize = Get-AzureRmVMSize -ResourceGroupName $RGName.ResourceGroupName -AvailabilitySetName $AvSet.Name | Out-GridView -Title "Select new VM Size" -OutputMode Single foreach ($VM in $VMs){ $vm = Get-AzureRmVM -ResourceGroupName $RGName.ResourceGroupName -VMName $vm.name $vm.HardwareProfile.VmSize = $NewVMSize.Name Update-AzureRmVM -VM $vm -ResourceGroupName $RGName.ResourceGroupName } |
So now my lab had the new V3 processor.
So what about the IP adres over what the VM’s communicate to the outside world> It remains the same!!
Untill next time!
Great and helpful item. Often they say I can’t change the VM size and you need to recreate it.