You are on page 1of 2

Basic Azure Resource Manager commands in Azure CLI

For more detailed help with specific command line switches and options, you can use
the online command help and options by typing az <command> <subcommand> --help.
Create VMs

Task Azure CLI commands

Create a resource az group create --name myResourceGroup --location eastus


group

Create a Linux az vm create --resource-group myResourceGroup --name myVM


--image ubuntults
VM

Create a az vm create --resource-group myResourceGroup --name myVM


--image win2016datacenter
Windows VM
Manage VM state

Task Azure CLI commands

Start a VM az vm start --resource-group myResourceGroup --name myVM

Stop a VM az vm stop --resource-group myResourceGroup --name myVM

Deallocate a az vm deallocate --resource-group myResourceGroup --name myVM


VM

Restart a VM az vm restart --resource-group myResourceGroup --name myVM

Redeploy a VM az vm redeploy --resource-group myResourceGroup --name myVM

Delete a VM az vm delete --resource-group myResourceGroup --name myVM

Get VM info

Task Azure CLI commands

List VMs az vm list

Get information about a az vm show --resource-group myResourceGroup --name


myVM
VM
Task Azure CLI commands

Get usage of VM az vm list-usage --location eastus


resources

Get all available VM sizes az vm list-sizes --location eastus

Disks and images

Task Azure CLI commands

Add a data disk to az vm disk attach --resource-group myResourceGroup --vm-name


myVM --disk myDataDisk --size-gb 128 --new
a VM

Remove a data disk az vm disk detach --resource-group myResourceGroup --vm-name


myVM --disk myDataDisk
from a VM

Resize a disk az disk update --resource-group myResourceGroup --name


myDataDisk --size-gb 256

Snapshot a disk az snapshot create --resource-group myResourceGroup --name


mySnapshot --source myDataDisk

Create image of a az image create --resource-group myResourceGroup --source


myVM --name myImage
VM

Create VM from az vm create --resource-group myResourceGroup --na


image

You might also like