In this blog post, we will show you how to resize Azure VM using the Azure PowerShell module.
The Azure PowerShell module is a set of cmdlets that enables users to manage their Azure resources through the PowerShell command-line interface. The module is built on top of the Azure Resource Manager (ARM) API, which provides a consistent management layer for all Azure services.
Note: To view all the available VM sizes visit this post.
Code
The following code uses Azure PowerShell 5.5 version number. You set the size you would like to resize the VM to in the $vm.HardwareProfile.VmSize
$vmname="vmname"
$rg_name="rgname"
# Get the VM
$vm = Get-AzVM -Name $vmname -ResourceGroupName $rg_name
# Choose a new size and resize the VM
$vm.HardwareProfile.VmSize = "Standard_DS1_v2"
# Update the VM with the new size
Update-AzVM -VM $vm -ResourceGroupName $rg_name
After executing the code, the VM restarts and will come up with a new size.
Leave a Reply