Resize a Linux virtual machine using CLI 2.0
After you provision a virtual machine (VM), you can scale the VM up or down by changing the VM size. In some cases, you must deallocate the VM first. You need to deallocate the VM if the desired size is not available on the hardware cluster that is hosting the VM. This article details how to resize a Linux VM with the Azure CLI 2.0.
Resize a VM
View the list of available VM sizes on the hardware cluster where the VM is hosted with az vm list-vm-resize-options. The following example lists VM sizes for the VM named
myVMin the resource group
az vm list-vm-resize-options --resource-group myResourceGroup --name myVM --output table
If the desired VM size is listed, resize the VM with az vm resize. The following example resizes the VM named
az vm resize --resource-group myResourceGroup --name myVM --size Standard_DS3_v2
The VM restarts during this process. After the restart, your existing OS and data disks are remapped. Anything on the temporary disk is lost.
If the desired VM size is not listed, you need to first deallocate the VM with az vm deallocate. This process allows the VM to then be resized to any size available that the region supports and then started. The following steps deallocate, resize, and then start the VM named
myVMin the resource group named
az vm deallocate --resource-group myResourceGroup --name myVM az vm resize --resource-group myResourceGroup --name myVM --size Standard_DS3_v2 az vm start --resource-group myResourceGroup --name myVM
Deallocating the VM also releases any dynamic IP addresses assigned to the VM. The OS and data disks are not affected.
For additional scalability, run multiple VM instances and scale out. For more information, see Automatically scale Linux machines in a Virtual Machine Scale Set.