This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Common Azure CLI commands for managing Azure resources
Applies to: ✔️ Linux VMs ✔️ Windows VMs ✔️ Flexible scale sets
The Azure CLI allows you to create and manage your Azure resources on macOS, Linux, and Windows. This article details some of the most common commands to create and manage virtual machines (VMs).
This article requires the Azure CLI version 2.0.4 or later. Run az --version to find the version. If you need to upgrade, see Install Azure CLI. You can also use Cloud Shell from your browser.
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
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 VM | az vm deallocate --resource-group myResourceGroup --name myVM |
| 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 VM | az vm show --resource-group myResourceGroup --name myVM |
| Get usage of VM resources | az vm list-usage --location eastus |
| Get all available VM sizes | az vm list-sizes --location eastus |
Disks and images
Next steps
For additional examples of the CLI commands, see the Create and Manage Linux VMs with the Azure CLI tutorial.
