Compute Resource Provider
The Resize-AzVM cmdlet resizes a virtual machine to a new size.
Resize-AzVM [-VM] <PSObject> [-VMSize] <String> [-AsJob] [-Force] [-WhatIf] [-Confirm]
Resize-AzVM -Name <String> -ResourceGroupName <String> [-VMSize] <String> [-AsJob] [-Force] [-WhatIf] [-Confirm]
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.
| 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. |
# 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"
# 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
Stop-AzVM cmdlet
with the -Force parameter.
Get-AzVMSize cmdlet.
For example: Get-AzVMSize -Location "eastus"