title | description | ms.topic | ms.service | ms.custom | keywords |
---|---|---|---|---|---|
Get started with Azure Command-Line Interface (CLI) | Learn how to get started with Azure CLI to manage Azure resources efficiently. This guide covers sign-in, essential commands, tab completion, and interactive mode. | concept-article | azure-cli | devx-track-azurecli | azure cli, how to use azure cli, azure command line interface, azure cli commands, azure cli tutorial |
Azure CLI is a cross-platform tool that simplifies managing Azure resources from the command line. Optimized for automation and ease of use, it supports interactive sessions and scripting with straightforward commands that integrate seamlessly with the Azure Resource Manager model. You can start using it in your browser with Azure Cloud Shell or install it locally to use from your preferred terminal.
The easiest way to try Azure CLI is through Azure Cloud Shell, a browser-based shell with no installation required. Cloud Shell supports Bash and PowerShell and comes with the latest version of Azure CLI preinstalled.
To install Azure CLI locally, see How to install Azure CLI.
To check your version, run:
az version
To start using Azure CLI with a local install, sign in:
[!INCLUDE interactive-login]
Important
[!INCLUDE MFA]
After you sign in, a list of your subscriptions appears. The one marked isDefault: true
is currently active. To change to a different subscription, run:
az account set --subscription "<subscription-id>"
For more information about subscription selection, see Manage Azure subscriptions. For advanced sign-in options, see Sign in with Azure CLI.
Azure CLI commands are organized as command groups. Each group represents an area of an Azure service. There are two options to find command groups:
Use the az find command. For example, to search for command names containing
vm
, use the following example:az find vm
Use the
--help
argument to get a complete list of subgroups within a reference group. The following example returns all subgroups for virtual machines:az vm --help
The following example shows the relevant portion of the output.
Subgroups: application : Manage applications for VM. availability-set : Group resources into availability sets. boot-diagnostics : Troubleshoot the startup of an Azure Virtual Machine. ...
The help output includes subgroups, parameters, authentication options, and examples.
Here's another example that finds the Azure CLI commands for grouping virtual machines into availability sets, a subgroup of
az vm
:az vm availability-set --help
You can also use
--help
to get parameter lists and command examples for a reference command.az vm create --help
Here is the relevant section of the example output:
Arguments --name [Required] : Name of the virtual machine. ... Authentication Arguments --admin-password : Password for the VM if authentication type is 'Password'. --admin-username : Username for the VM... ... Managed Service Identity Arguments ... Examples Create a VM from a custom managed image. az vm create -g MyResourceGroup -n MyVm --image MyImage ...
Use the reference index that lists all command groups alphabetically.
For usage examples, see:
The Samples index for Azure CLI examples by subject, reference group, or GitHub repo.
The Article index to find in-depth guides. Use your keyboard
find
shortcut keys, likeCtrl + F
, to quickly find the reference command group in which you're interested. For example, the article index foraz vm
looks like the following table:Reference subgroup Azure CLI article showing reference use az vm Output formats for Azure CLI commands How to use variables in Azure CLI commands Get VM information with queries {More articles listed here.} az vm aem New Version of Azure VM extension for SAP solutions Standard Version of Azure VM extension for SAP solutions az vm application {...}
Azure CLI supports tab completion in Bash. To enable it in PowerShell, see Enable tab completion in PowerShell.
Common arguments available to most commands include:
Argument | Description |
---|---|
--help | View command help |
--output | Change output format: json , jsonc , tsv , table , yaml |
--query | Filter output using JMESPath |
--verbose | Print more execution details |
--debug | Show low-level REST calls for debugging |
--subscription | Specify subscription name or ID |
--only-show-errors | Suppress noncritical output |
For more information, see Output formats and Query results.
Run interactive mode with:
az interactive
Interactive mode launches an enhanced Azure CLI experience with inline help and command suggestions. For more, see Interactive Mode.
An optional VS Code extension provides similar features with autocomplete and hover tips.
Get hands-on with Azure CLI basics using the onboarding tutorial. You learn how to:
- Manage your default subscription
- Create resources with randomized names
- Use environment variables
- Debug commands and parse JSON files
- Delete resources efficiently
Note
Azure CLI examples on Microsoft Learn are written for Bash. One-liners usually work across shells, but multiline scripts may require adjustments. For more information, see Learn syntax differences between Bash, PowerShell, and Cmd
We welcome your feedback. Submit issues on GitHub or run:
az feedback