Azure PowerShell Cmdlets

Compute Resource Provider

Resize-AzVM

The Resize-AzVM cmdlet resizes a virtual machine to a new size.

Syntax

CmdletBinding()
Resize-AzVM
   [-VM] <PSObject>
   [-VMSize] <String>
   [-AsJob]
   [-Force]
   [-WhatIf]
   [-Confirm]
Resize-AzVM
   -Name <String>
   -ResourceGroupName <String>
   [-VMSize] <String>
   [-AsJob]
   [-Force]
   [-WhatIf]
   [-Confirm]

Description

The Resize-AzVM cmdlet resizes a virtual machine to a new size. You can use this cmdlet to change the size of a virtual machine to accommodate changing workload requirements. The virtual machine must be in a stopped deallocated state before it can be resized.

Parameters

Name Type Description
-VM PSObject Specifies the virtual machine object to resize. You can use the Get-AzVM cmdlet to get the virtual machine object.
-VMSize String Specifies the new size for the virtual machine. For a list of available VM sizes, use Get-AzVMSize.
-Name String Specifies the name of the virtual machine.
-ResourceGroupName String Specifies the name of the resource group that the virtual machine belongs to.
-AsJob SwitchParameter Run cmdlet in the background.
-Force SwitchParameter Overrides confirmation prompts.
-WhatIf SwitchParameter Shows what would happen if the cmdlet runs. The cmdlet is not run.
-Confirm SwitchParameter Prompts you for confirmation before running the cmdlet.

Examples

Example 1: Resize a virtual machine by name
# Stop the virtual machine
                Stop-AzVM -ResourceGroupName "resourcegroup1" -Name "vm1"

                # Resize the virtual machine
                Resize-AzVM -ResourceGroupName "resourcegroup1" -Name "vm1" -VMSize "Standard_D2s_v3"

                # Start the virtual machine
                Start-AzVM -ResourceGroupName "resourcegroup1" -Name "vm1"
Example 2: Resize a virtual machine using a VM object
# Get the virtual machine object
                $vm = Get-AzVM -ResourceGroupName "resourcegroup1" -Name "vm2"

                # Stop the virtual machine
                Stop-AzVM -VM $vm

                # Resize the virtual machine
                Resize-AzVM -VM $vm -VMSize "Standard_D4s_v3"

                # Start the virtual machine
                Start-AzVM -VM $vm

Notes

Before resizing a virtual machine, it must be in a stopped deallocated state. You can stop and deallocate a virtual machine using the Stop-AzVM cmdlet with the -Force parameter.
To find available VM sizes in a region, use the Get-AzVMSize cmdlet. For example: Get-AzVMSize -Location "eastus"
Resizing a virtual machine can incur costs. Ensure you understand the pricing for the new VM size before proceeding.

See Also