az-vm
Manage Azure virtual machines
TLDR
SYNOPSIS
az vm command [options]
DESCRIPTION
az vm manages Azure virtual machines. It provides commands for creating, starting, stopping, configuring, and deleting VMs, as well as managing disks, network interfaces, and extensions.
The command group enables full lifecycle management of Azure compute resources.
PARAMETERS
create
Create new virtual machinelist
List virtual machinesstart
Start VMstop
Stop VM (still incurs compute charges)deallocate
Deallocate VM (stops billing for compute)restart
Restart VMdelete
Delete VMshow
Get VM details--resource-group, -g name
Resource group name--name, -n name
VM name--image
OS image (Ubuntu2204, Win2022Datacenter, etc.)--size
VM size (StandardB2s, StandardD2s_v3, etc.)--admin-username
Admin username--admin-password
Admin password--ssh-key-values
SSH public key(s)
COMMON OPERATIONS
az vm create -g MyRG -n MyVM --image Ubuntu2204 --ssh-key-values ~/.ssh/id_rsa.pub
# Get VM IP address
az vm show -g MyRG -n MyVM -d --query publicIps -o tsv
# Resize VM
az vm resize -g MyRG -n MyVM --size Standard_D4s_v3
# Run command on VM
az vm run-command invoke -g MyRG -n MyVM --command-id RunShellScript --scripts "apt-get update"
CAVEATS
Creating VMs incurs costs. az vm stop does not deallocate -- use az vm deallocate to stop billing for compute. Some VM sizes are not available in all regions. Deleting a VM does not delete associated resources (disks, NICs) by default. The UbuntuLTS image alias was deprecated in 2023; use Ubuntu2204 or similar instead.
HISTORY
az vm has been part of Azure CLI since version 2.0 in 2017, providing comprehensive VM management capabilities.
SEE ALSO
az(1), az-group(1), az-network(1)

