Azure cli reference

Azure cli reference DEFAULT

Get started with Azure CLI


Get started with Azure Command-Line Interface (CLI) | Microsoft Docs

Learn how to start using the Azure CLI by completing common commands. You can begin using the Azure CLI by running it in an Azure Cloud shell environment.








devx-track-azurecli, seo-azure-cli

azure cli, how to use azure cli, azure command line interface, how to open azure cli, azure cli commands

Welcome to the Azure Command-Line Interface (CLI)! This article introduces the CLI and helps you complete common tasks.


In scripts and on the Microsoft documentation site, Azure CLI examples are written for the shell. One-line examples will run on any platform. Longer examples which include line continuations () or variable assignment need to be modified to work on other shells, including PowerShell.

Install or run in Azure Cloud Shell

The easiest way to learn how to use the Azure CLI is by running it in an Azure Cloud Shell environment through your browser. To learn about Cloud Shell, see Quickstart for Bash in Azure Cloud Shell.

When you're ready to install the CLI, see the installation instructions.

After installing the CLI for the first time, check that it's installed and you've got the correct version by running .

[!NOTE] If you're using the Azure classic deployment model, install the Azure classic CLI.

How to sign into the Azure CLI

Before using any Azure CLI commands with a local install, you need to sign in with az login.

[!INCLUDE interactive-login]

After logging in, you see a list of subscriptions associated with your Azure account. The subscription information with is the currently activated subscription after logging in. To select another subscription, use the az account set command with the subscription ID to switch to. For more information about subscription selection, see Use multiple Azure subscriptions.

There are ways to sign in non-interactively, which are covered in detail in Sign in with Azure CLI.

Common Azure CLI commands

This table lists some common commands used in the CLI and links to their reference documentation.

Finding commands

Azure CLI commands are organized as commands of groups. Each group represents an Azure service, and commands operate on that service.

To search for commands, use az find. For example, to search for command names containing , use the following command:

Use the argument to get a complete list of commands and subgroups of a group. For example, to find the CLI commands for working with Network Security Groups (NSGs):

The CLI has full tab completion for commands under the bash shell.

Globally available arguments

There are some arguments that are available for every command.

  • prints CLI reference information about commands and their arguments and lists available subgroups and commands.
  • changes the output format. The available output formats are , (colorized JSON), (Tab-Separated Values), (human-readable ASCII tables), and . By default the CLI outputs . To learn more about the available output formats, see Output formats for Azure CLI.
  • uses the JMESPath query language to filter the output returned from Azure services. To learn more about queries, see Query command results with Azure CLI and the JMESPath tutorial.
  • prints information about resources created in Azure during an operation, and other useful information.
  • prints even more information about CLI operations, used for debugging purposes. If you find a bug, provide output generated with the flag on when submitting a bug report.

Interactive mode

The CLI offers an interactive mode that automatically displays help information and makes it easier to select subcommands. You enter interactive mode with the az interactive command.

For more information on interactive mode, see Azure CLI Interactive Mode.

There's also a Visual Studio Code plugin that offers an interactive experience, including autocomplete and mouse-over documentation.

Learn CLI basics with quickstarts and tutorials

To learn how to use the Azure CLI, try an in-depth tutorial for setting up virtual machines and using the power of the CLI to query Azure resources.

[!div class="nextstepaction"] Create virtual machines with the Azure CLI tutorial

There are also quickstarts for other popular services.

Give feedback

We welcome your feedback for the CLI to help us make improvements and resolve bugs. You can file an issue on GitHub or use the built-in features of the CLI to leave general feedback with the az feedback command.

See also


Azure CLI Overview: Setup, Comparison, and Integration Tips

If you are just learning about Azure, most likely you are working in the Azure Portal. You have probably created resources like virtual machines and storage accounts by using the deployment wizards. However, this process is tedious and doesn’t scale when you need to create lots of resources. If you want to take your Azure resource deployment to the next level, it is time to look at the Azure CLI!

In this tutorial, you will learn what the Azure CLI is, how to connect to your Azure tenant, and how to deploy your first resources. If you are more familiar with Azure PowerShell, you will also learn some differences between the two languages.

What is Azure CLI?

azure cli definition

Azure CLI is a command-line tool to create and manage resources. You interact with Azure by running commands in a terminal or writing scripts to automate tasks. Azure CLI interacts with the Azure Resource Manager (ARM) service, which is the management layer to interact with resources in your account.

Azure CLI Features

The Azure CLI offers many great features for managing Azure resources.

  • Cross-Platform: You can install Azure CLI on Linux, Mac, or Windows computers. You can even run Azure CLI from inside a Docker container.
  • Multiple Shell Environments: Azure CLI works in multiple shell environments, such as Windows Command prompt, Bash, and PowerShell.
  • Bash-like Syntax: If you are a Linux administrator, the Azure CLI syntax is similar to Bash scripting. This similarity helps Azure CLI feel more natural and easy to learn.
  • Automation: You can automate Azure management tasks by writing scripts with Azure CLI, such as creating, modifying, or deleting resources.
  • Open-Source: Microsoft hosts the source code for Azure CLI in GitHub, and community members can contribute to the project.

Azure CLI can also work with infrastructure as code languages like ARM templates and Azure Bicep. To learn more about these infrastructure as code formats, check out the articles below!

Exploring ARM Templates: Azure Resource Manager Tutorial

Azure Bicep: Getting Started and How-To Guide

How to Install Azure CLI

Now that you understand a bit more about the Azure CLI, it’s time to get it installed! As mentioned above, Azure CLI is cross-platform, meaning you can install it on most platforms. Check out the following sections on how to install the Azure CLI on the platform of your choice.


For Windows-based systems, Microsoft provides an MSI installer for the Azure CLI. The MSI is for new installations and upgrades to existing versions. You can find the current release of the Azure CLI here.

As an alternative, you can use PowerShell commands to download and install the latest version of Azure CLI. The example code below shows how to download and install Azure CLI. Be sure to run the following steps from PowerShell started as an administrator. Once the installation is successful, restart the PowerShell console to use the Azure CLI commands.

# Download the latest MSI installer and save as AzureCLI.msi Invoke-WebRequest -Uri -OutFile .\AzureCLI.msi # Start the installation and wait for completion Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet' # Remove the downloaded MSI installer Remove-Item .\AzureCLI.msi


The Azure CLI is available for multiple Linux distributions such as Ubuntu, Debian, Red Hat, CentOS, and more. Microsoft recommends installing the Azure CLI using your Linux distribution’s preferred package manager so you can make sure to always get the latest updates.

If you don’t have any of the above package managers available, you can manually install Azure CLI across all Linux platforms. To manually install Azure CLI, your system requires the following software:

To install or update Azure CLI, run the following script:

curl -L | bash


You install Azure CLI on the macOS platform using the homebrew package manager. Homebrew is an easy way to keep your Azure CLI installation up to date. Azure CLI currently supports macOS version 10.9 and later.

To install Azure CLI on your macOS system, update your brew repository information and run the install command, like this:

brew update && brew install azure-cli

Azure Cloud Shell

If you don’t want to manage Azure CLI on your local system, you can use the Azure Cloud Shell. The Azure Cloud Shell is an interactive shell environment that runs in your browser. It automatically authenticates to your Azure tenant so you can quickly start managing resources.

The Azure Cloud Shell provides both Bash and PowerShell experiences so you can pick your favorite. Each environment automatically includes the latest version of the Azure CLI. Below is a screenshot showing the Bash shell and running to display the Azure CLI version.


To access the Azure Cloud Shell, navigate to If you’ve never accessed the shell before, you are prompted to create a storage account for persisting files across sessions. To read more about this process, checkout persisting files in Azure Cloud Shell.

Azure CLI vs. Azure PowerShell

Azure CLI and Azure PowerShell are command-line tools that allow you to manage your Azure resources and environment. Both tools support installation on Windows, macOS, and Linux. However, Azure CLI supports more shell environments, like Windows Command prompt and Bash, whereas Azure PowerShell is only supported in PowerShell.

Check out the table below for a comparison of support shell environments.

cli vs powershell
When choosing which command-line tool is right for you, consider your past experience and what type of environment you work in. If you are primarily a Linux administrator, the Azure CLI syntax is similar to Bash scripting. Learning Azure CLI may feel more natural than learning Azure PowerShell.

The Azure CLI follows a syntax where each commands begins with the reference name followed by the name of a resource. After the reference name is the command name, which designates which resource you are working with. Finally, many commands also have parameters for passing values, such as a resource group name.

Below is an image that shows an example command to set the Azure subscription. Setting the Azure subscription tells Azure CLI where to create or find resources to manage. The example command shows the reference name (), the command (), the parameter name (), and the parameter value ().

If you primarily work in a Windows environment, Azure PowerShell may be the better choice. All Windows operating systems come with PowerShell already installed. Azure PowerShell is a PowerShell module you install from the PowerShell Gallery.

While you may develop a preference for a command-line tool, it is important to be familiar with both. Both tools do not have full feature parity for Azure services, so you may need to use one tool when the other doesn’t support a service or command.

To learn more about managing Azure and Office 365 using PowerShell, check out How to Connect to Office 365 PowerShell: Azure AD Modules.

Managing Resources with Azure CLI

Now that you understand the Azure CLI a bit more, it is time to see it in action! The following sections demonstrate how to access your tenant, view your subscriptions, and create a few Azure resources.

Signing in to Azure

Azure CLI supports multiple authentication methods to sign in to your Azure environment. The default authentication method uses an interactive log-in through a web browser. Run the command to get started, and the CLI will open your default browser to an Azure sign-in page. Enter your credentials or select an already signed-in account to complete the sign-in process.

If a browser doesn’t open automatically, you can use an authorization code to sign in to Azure. Add the parameter to the same log-in command. Navigate to the URL ( and enter the authorization code. Once Azure verifies the authorization code, you then enter your user name and password.

Selecting an Azure Subscription

When you sign in to your Azure tenant, the Azure CLI displays a list of subscriptions you have access to. Azure subscriptions are a logical grouping of resources for billing and management purposes. If you don’t make any changes, Azure CLI uses the default subscription when you start creating resources.

Use the command to view the default subscription. In the example screenshot below, the default subscription is named Demo and has a unique ID starting with 5b5.

default sub

If you need to view all subscriptions later in your session, use the command. Azure CLI displays information about each subscription, such as the unique ID and name. Find the subscription you want to work with and note either the ID or name.

In the example screenshot below, the subscription name starts with 7458, and the name is Production.

production sub

If you need to switch subscriptions before creating new resources, use the command. The example below sets the subscription to Production. When selecting another subscription, you can use the subscription ID or display name.

# Set the subscription using the display name az account set --subscription “Production” # Set the subscription using the unique ID az account set --subscription 7458ed71-ed9d-45f4-b34e-793a2472800f

Creating Resources using Azure CLI

Now that you are logged into Azure and selected your subscription, it is time to create some resources! In the remaining steps, you will make a resource group followed by creating a storage account.

To create a resource group, use the command followed by the group name (AzureCliDemo) and the Azure region (WestUS2). You can select any name and Azure region you’d like.

az group create --name ‘AzureCliDemo’ --location ‘WestUS2’

create rg

With the resource group created, create the storage account using the command. Specify a globally unique storage account name (azclistfacctdemo) along with the resource group name (AzureCliDemo) and Azure location (WestUS2).

Next, specify the storage account properties, such as the SKU (Standard_LRS), the kind of storage account (StorageV2), and the default access tier (Cool).

az storage account create ` --name 'azclistgacctdemo' ` --resource-group 'AzureCliDemo' ` --location 'WestUS2' ` --sku 'Standard_LRS' ` --kind 'StorageV2' ` --access-tier 'Cool'

Congratulations! You just created your first resources using the Azure CLI!

Azure CLI FAQs

What is Azure CLI used for?

Azure CLI is a command-line utility used to create and manage Azure resources. You can use the Azure CLI to issue single commands to your Azure environment or write a script with several commands to automate a task.

What is the difference between Azure CLI and Azure PowerShell?

Azure CLI and Azure PowerShell use different syntax to accomplish their actions. While both work on multiple platforms, Azure CLI works in shell environments that Azure PowerShell does not, like Windows Command prompt and Bash on Linux.


In this article, you learned about the Azure CLI and the benefits of using it. You then saw how you can install Azure CLI on multiple platforms and then signed in to your Azure tenant and created your first resources.

Azure CLI is a fantastic tool to learn to manage your Azure environment. By leveraging Azure CLI, you can accomplish tasks more quickly and standardize repeatable tasks. The Bash-like syntax makes the Azure CLI a natural choice for your shell experience if you’re a Linux administrator.

Jeff Brown

Jeff Brown

Jeff Brown is a cloud engineer specializing in Microsoft technologies such as Office 365, Teams, Azure and PowerShell. You can find more of his content at

  1. Hidden valley home rentals
  2. Pathfinder languages
  3. History of tf2
  4. Jade good fortune necklace

Adam the Automator


If you have a Microsft Azure account and are still managing resources only through the Azure Portal, you’re missing out. One of the best ways to reduce clicking and increase productivity is by using the Azure CLI.

The Azure CLI is a cross-platform toolset written in Python that allows you to manage nearly all of your Azure resources from the command line. No matter what operating system you’re on, the Azure CLI provides a consistent experience across all platforms.

In this tutorial, you’re going to learn how to get started with the Azure CLI. You’ll learn how to perform an initial configuration and create and remove some common resources using various Azure CLI commands.


This article will be a tutorial. If you plan on following along step-by-step, you will need at least one of the following:

  • Azure CLI – This tutorial will be using v2.20.0 on a Docker Container, but the commands will work all the same on other platforms.

Related:How to Install the Azure CLI (Windows, Linux, macOS, Azure Shell)

  • Permissions to create resources within Azure via a Microsoft account perhaps using a service principal.

Related:Azure Service Principals: How to Create (And Understand) Them

Getting Help with

Before you run any command in the Azure CLI, learn how to use the command. The Azure CLI has rich and plentiful help in the Azure CLI. This tutorial can’t possibly cover all commands so learning how to use is critical.

To get started, let’s navigate around the help system and check out how to find further information on various commands.

Navigating a Typical Help Example

Examples make the best learning material. Let’s cover how to use the Azure CLI help system by walking through an example of finding the needed command to create a resource group in Azure.

With your terminal open:

1. Run the command. This command returns two types of output; groups and subgroups.

Commands are organized as groups. You’ll typically see tutorials (and even documentation) refer to groups as “commands”. Groups are broken out in a hierarchical fashion with each group representing an Azure service.

output of az help

2. Scroll down until you find the subgroup called . You can see from the description below, this subgroup is responsible for managing resource groups. Groups are ordered alphabetically.

scrolling down to find group

3. Once you’ve found the command you’re looking for, run it using the parameter. Using the parameter doesn’t make any changes; it returns all help documentation for a group or command.

You can see below the group and a single subgroup () with various commands inside.

output of az group help

4. Since you want to create a resource group, the command looks like the right command. Now continue getting more specific by appending a more granular command to the original reference and finding help.

Reference the parameter on any command to see it’s help documentation.

The parameter now displays information about the command. Commands have arguments as shown below. In this example, you now have the arguments required to specify a resource group and required .

help parameter

Finding Syntax Examples with

If you can’t easily find the group or command you’re looking for with the parameter, take a look at the command. This command searches for syntax examples using group/command references as shown below.

For example, instead of navigating the help system with as shown above, perform the same task with a single line with .

output of find command

Assigning a Default Configuration with

The Azure CLI has many commands and features. Each of these features has various configurations they reference like logging and data collection preferences. One of the first tasks you should complete when setting up the Azure CLI for the first time is running the command.

In one command, the command walks you through three different settings:

  • Output Format – Seven different different ways that the Azure CLI returns output
  • Logging – The ability to log all Azure CLI activity to a file
  • Telemetry – To enable or disable sending information to Microsoft about how you use Azure CLI

To get started, assuming you already have the Azure CLI installed:

1. Open a terminal (Bash or PowerShell).

2. Type in the command . You’ll be prompted with a simple menu letting you know that all settings will be stored in the .azure/config file. Press Y to continue.

output from azconfigure

3. The command will first prompt you for your desired default output format. Here, pick your desired output. The default output format sets how your output will appear on the screen after executing a command or receiving an error message.

If you're unsure, below you'll find some examples.

The below examples use the parameter. Regardless of what format you pick as the default, you can always override the default output with the parameter.

JSON (Java Object Notation)

json output

JSONC (Java Object Notation with comments\colorization)

jsonc output


table output

TSV (Tab-Separated Values)

tsv output

YAML (YAML Ain’t Markup Language)

yaml output

YAMLC (YAML with comments\colorization)

None – The Azure CLI will only return errors or warning.

4. Once you’ve set the output format, the Azure CLI will prompt you to enable logging. Here, select to enable logging all commands and output to a file.

Output Format

Selecting here will create a log containing all the commands and output collected while using the CLI. This log is located in the $HOME/.azure/logs directory in Linux and macOS and %USERPROFILE%\.azure\logs in Windows.

Below you can see an example of what the log would look like.

Log file contents after executing az login

5. The Azure CLI will then ask you to send telemetry data to Microsoft. Selecting here will send anonymous information to Microsoft on how you use the Azure CLI.

Telemetry Data

For more information on the information that Microsoft collects, refer to Microsoft’s privacy information on collecting anonymous data from Azure CLI.

Finally, will ask to set the CLI object cache time-to-live value. You should leave this set at the default of 10.

cli object cache setting

Only change the CLI object TTL if advised by Microsoft when troubleshooting an issue with the Azure CLI.

Setting Default Parameter Values

The Azure CLI has various commands with the same parameters such as location and group. Rather than key in the values for these parameters every time for every command, you can set default parameter values.

To set parameter defaults, use the parameter on . This parameter allows you to define a parameter and it’s default value. For example, perhaps you’re tired of typing in a and for various commands. No problem. Set a couple of default values.

The following example sets the default region () to and the resource group () to . Now whenever you run any Azure CLI command that has a or parameter, Azure CLI will automatically pass values to those parameters.

If you are using containers, you could set individual containers to manage specific regions, subscriptions or resource groups by setting the defaults in each container instance. You could create 4 containers in each container using az configure to set a default region and a default resource group using the command above.

Authenticating with a Browser

You’ve now learned the basics of using the Azure CLI, but you haven’t actually done anything yet. Let’s now take that step into creating some resources! But first, you must log in to Azure, using the command, .

If you have multiple Azure subscriptions, run the command to find all subscriptions. When you find the subscription, run to set the subscription to use for the session. You can also use the global parameter to explicitly specify a subscription.

1. Open a terminal and run . This command opens a browser window that takes you to a page to provide your username and password.

az login in Powershell session

2. Provide your Azure account credentials or click on an existing user account as shown below.

authenticate with Microsoft

3. Once Azure authenticates your account, close your web browser and return to your Azure CLI session. The command returns information about your subscription to confirm you now have an authentication token.

Output from az login, once authenticated

Authenticating Using a Device Code

If you’re on a system without a browser or want to download an authentication token on another computer, use the parameter. This parameter allows a user to use a code supplied from another device to authenticate the user.

To authenticate using a device code, open a terminal and:

Run using the parameter. The command, this time, will not open a browser. Instead, it will provide a code to provide to the device login page on another computer.

output of az-login —use-device-code

2. On a different computer, navigate to, paste in the code supplied, and click Next.

Enter code to authenticate

3. Now enter your credentials to authenticate to Azure and close your browser, if not needed.

choosing an account to authenticate with

Back in the Azure CLI session, will return your subscription information.

verification your session is logged on to azure

Azure CLI Output Options

As mentioned, the Azure CLI can return output in different ways. You can define the default output and change it on the fly with the parameter. But the parameter isn’t the only parameter that changes output behavior.

To change up the verbosity, filter output or modify error output behavior, use the following parameters.

  • – Uses the JMESPath query language to filter output for all commands. Reference this article to learn more.
  • – Returns information about resources created in Azure and extended information about those resources.
  • – Returns a low-level amount of information about CLI operations used for debugging.
  • – Show errors and suppress warnings.

Creating a Resource Group

Now that you’re authenticated to Azure, you’re free to manage all of the resources you have permission to. Let’s first run through a common example of creating a resource group.

Assuming you’re on a computer with the Azure CLI installed and you’ve already authenticated to Azure with the CLI:

Create a resource group using the command as shown below. This command is creating a called TESTGrp in the North Europe and returning all output.

output of az group create

2. Now confirm Azure created the resource.

Notice that you’ve created the TESTGrp resource group.

output of az group list

3. Perhaps you have a lot of resource groups to sift through. Instead of scrolling, use the parameter to narrow down the list. The below command only returns resource groups in the North Europe using JMESPath.

output of a JMESPath query

Creating A Linux Virtual Machine

For this last example, learn how to create an Azure VM with the Azure CLI. Creating virtual machines and the configuration around them is a good skill to learn. Creating Azure VMs is a common task you may perform repeatedly during your cloud journey.

In this exercise, you’ll create an Azure Linux VM with default settings and deploy it into the resource group created in the previous section.

An Azure VM consists of many Azure resources all working together like a disk image, virtual network adapter, virtual machine, and so on.

To create an Azure VM with the Azure CLI:

1. Run the command to find all available VM images for the VM. This command returns all of the cached/offline images.

For this demo, choose the image as highlighted below.

Cached list of images available

The Azure CLI maintains a cached list of all VM images. If the UbuntuLTS image doesn’t show up, use the parameter to get an updated list.

2. Once you know the disk image to use for the VM, create the VM with . The code snippet below creates a VM of ATAVM1 using the UbuntuLTS in the TESTGrp. When Azure creates the VM, it will generate the SSH keys () to connect to it later and return output in JSON ().

Split a single longer Azure CLI commands on separates lines using a trailing backslash.

The command has many more ways to configure building a VM. Remember the help system is your friend!

If the command was initiated successfully, you should see something similar to the screenshot below.

VM being created

By using the parameter, you will see the actual REST API method and parameters used in green.

3. When the deployment completes, the last section of the output will display information about your VM. Most notably for this demo, copy the public IP address. You’ll need this to connect to the VM over the Internet.

output from vm creation

At this point, now connect to the Ubuntu VM via SSH using the VM’s public IP address found above. To do so, open your favorite SSH client and connect to the VM as the user azureuser as shown below. By default, the command creates a local user called azureuser.

Related:Setting up SSH in Linux

connected to the vm created

You were able to SSH to the VM without a password because you used the parameter when creating the VM. This downloads the private key to your ~/.ssh directory and uploads the public key to the VM allowing you to authenticate.

5. Now clean up the VM and the resource group.

Next Steps

You should now have the Azure CLI ready to go. You’re now ready to manage some resources! So what next?

More from Adam The Automator & Friends


Azure Cli Commands: Login, set default subscription, create resource group \u0026 storage account

Microsoft Azure CLI

PythonBuild StatusSlack

A great cloud needs great tools; we're excited to introduce Azure CLI, our next generation multi-platform command line experience for Azure.

Take a test run now from Azure Cloud Shell!


Please refer to the install guide for detailed install instructions.

A list of common install issues and their resolutions are available at install troubleshooting.

Developer installation (see below)


$ az [ group ] [ subgroup ] [ command ] {parameters}

Get Started

Please refer to the "get started" guide for in-depth instructions.

For usage and help content, pass in the parameter, for example:

$ az storage -h $ az vm create -h


Here are a few features and concepts that can help you get the most out of the Azure CLI.

Azure CLI Highlight Reel

The following examples are showing using the format, you can change your default using the command.

Tab completion

We support tab-completion for groups, commands, and some parameters

# looking up resource group and name $ az vm show -g [tab][tab] AccountingGroup RGOne WebPropertiesRG $ az vm show -g WebPropertiesRG -n [tab][tab] StoreVM Bizlogic $ az vm show -g WebPropertiesRG -n Bizlogic


You can use the parameter and the JMESPath query syntax to customize your output.

$ az vm list --query "[?provisioningState=='Succeeded'].{ name: name, os: storageProfile.osDisk.osType }" Name Os ---------------------- ------- storevm Linux bizlogic Linux demo32111vm Windows dcos-master-39DB807E-0 Linux

Exit codes

For scripting purposes, we output certain exit codes for differing scenarios.

Exit CodeScenario
0Command ran successfully.
1Generic error; server returned bad status code, CLI validation failed, etc.
2Parser error; check input to command line.
3Missing ARM resource; used for existence check from commands.

Common scenarios and use Azure CLI effectively

Please check Tips for using Azure CLI effectively. It describes some common scenarios:

More samples and snippets

For more usage examples, take a look at our GitHub samples repo or

Write and run commands in Visual Studio Code

With the Azure CLI Tools Visual Studio Code extension, you can create files and use these features:

  • IntelliSense for commands and their arguments.
  • Snippets for commands, inserting required arguments automatically.
  • Run the current command in the integrated terminal.
  • Run the current command and show its output in a side-by-side editor.
  • Show documentation on mouse hover.
  • Display current subscription and defaults in status bar.
  • To enable IntelliSense for other file types like or , see microsoft/vscode-azurecli#48.

Azure CLI Tools in Action

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Telemetry Configuration

Telemetry collection is on by default. To opt out, please run to turn it off.

Reporting issues and feedback

If you encounter any bugs with the tool please file an issue in the Issues section of our GitHub repo.

To provide feedback from the command line, try the command.

Developer installation


We maintain a Docker image preconfigured with the Azure CLI. See our Docker tags for available versions.

$ docker run -u $(id -u):$(id -g) -v ${HOME}:/home/az -e HOME=/home/az --rm -it<version>

Edge builds

If you want to get the latest build from the branch, you can use our "edge" builds.

You can download the latest builds by following the links below:

You can easily install the latest Homebrew edge build with the following command:

brew install $(curl -Ls -o /dev/null -w %{url_effective}

You can install the edge build on Ubuntu Xenial with the following command:

curl -Ls -o azure-cli_xenial_all.deb && dpkg -i azure-cli_xenial_all.deb

And install the edge build with rpm package on CentOS/RHEL/Fedora:

rpm -ivh --nodeps $(curl -Ls -o /dev/null -w %{url_effective}

Here's an example of installing edge builds with pip3 in a virtual environment. The option will install the edge builds of dependencies as well.

$ python3 -m venv env $ . env/bin/activate $ pip3 install --pre azure-cli --extra-index-url --upgrade-strategy=eager

To upgrade your current edge build pass the option. The option is also recommended since the feed is frequently updated.

$ pip3 install --upgrade --pre azure-cli --extra-index-url --no-cache-dir --upgrade-strategy=eager

The edge build is generated for each PR merged to the branch as a part of the Azure DevOps Pipelines.

Get builds of arbitrary commit or PR

If you would like to get builds of arbitrary commit or PR, see:

Try new features before release

Developer setup

If you would like to setup a development environment and contribute to the CLI, see:

Configuring Your Machine

Authoring Command Modules

Contribute code

This project has adopted the Microsoft Open Source Code of Conduct.

For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

If you would like to become an active contributor to this project please follow the instructions provided in Microsoft Open Source Guidelines.


Cli reference azure

Getting Started with Azure CLI

Azure CLI provided by Microsoft is a cross-platform command-line tool for managing Azure resources and automating cloud resource deployment. The tool enables you to query, create and manage the cloud resources using the terminal.

In this article, you'll see how to authenticate using various methods and get familiar with some of the common Azure CLI commands for regular use like getting help and finding example commands in Azure CLI modules.

Table Of Content

  1. Prerequisites
  2. Authenticate to Azure CLI
  3. Working with Azure CLI Commands
  4. Using Azure CLI Help with az help
  5. Using Azure CLI Find Module
  6. Using Azure CLI Query Module
  7. Working with Azure CLI Output Options
  8. Setting up Azure CLI Default Configuration
  9. Conclusion
  10. Reference


This is the second article in the series of Azure CLI. If you haven't installed the CLI tools yet, check out the first post in the series:

How to Install Azure CLI: A Complete Guide

Learn All the Ways to Install Azure CLI on Ubuntu, Windows, macOS, and RedHat

Before you go into the article, you should be familiar with the basic concept of

Authenticate to Azure CLI

There are several ways to authenticate to the Azure environment using Azure CLI. Once logged in, the CLI allows you to query and interact with the cloud resources. Cloud Shell is the easiest way to use Azure CLI without logging in using CLI but the Azure Portal. However, while doing complex scripting, it's most likely that you need to authenticate to the cloud using your device or development environment.

In the following few sections, you will see multiple ways that you can use to log in to the Azure environment using Azure CLI. We'll be covering CLI usage in the section after authentication for the sake of being logged into your account before you use any queries.

Authenticate using a Browser

While working on Windows or macOS devices, it's convenient to log in to the terminal session without having to type in the username password again if you are already logged in to Azure Portal on a browser session.

Follow the instruction below to log in to Azure using Azure CLI:

  • Navigate to the Start menu on Windows and launch PowerShell or search for Terminal on macOS:
  • Run the following command to initiate the login session:

In this command, the module for Azure CLI is used to interact with the Azure Environment. The command launches an authenticated session to the Azure portal for ongoing resource management. You don't need to sign in for each action as the session is stored as an authentication refresh token locally.

  • The terminal will show the following text, displaying the further actions on the authentication process through the default browser:

Ignore the warning for the device code on the last line for now. We'll be covering that in the next section.

  • Follow the instruction on your browser to login to the Azure Account:
  • Once the authentication is successful, you will see the confirmation on the browser:
  • At this point, you can close the browser and return to the terminal. The output on the terminal will show the list of subscriptions you have access to in your account:

Authenticate using a Device Code

There might be a case when you are using an SSH or WSL system that doesn't have any GUI interaction or direct access to launch a browser or want to authenticate without letting Azure CLI launch the browser session.

Follow the steps below to authenticate to your Azure account using a device code that can authenticate your CLI session from either same or any device logged in to Azure:

  • Launch your terminal and type the following command:

Using the flag tells the CLI to authenticate with the code and lets you decide the device of login and the account.
  • You'll be prompted to enter the device code. Use the device code that looks like EU5KMLTHK in this case, from your command line output and paste here:
  • Once confirmed, you'll see the output displaying a success message:
  • Navigate back to your terminal and review the output that displays your login session information along with tenant and subscription information:

Authenticate using Username and Password

If opening a browser to authenticate or copy-pasting the device code is not feasible for your case, or if it's too much hassle, you can use the username and password directly for your Azure account to log in.

It's worth mentioning that this is not a recommended method since it's the least secure method of all other login forms. I'd recommend using other methods over this where possible unless this is the last option to resort to for you.

Follow the steps below to login to Azure CLI using username and password:

  • Run the following command in your terminal:

Replace the and with your Azure account email and password before pressing Enter.

  • The command will authenticate you directly and displays the subscription access for your account:
The accounts with MFA or Two-factor authentication may not be able to log in using this method. Consider using device code, or the Service Principal method explained below to login instead.

Authenticate using a Service Principal

Service Principals are service accounts that are not real user account; however, they can have permissions or roles just like user accounts. Service principals have a time-bound secret as a password to log in, which is valid for six months or more and needs to be renewed once expired.

The method of service principal login is super helpful when running scripts in the background on a schedule where you don't want someone to go and put the device code whenever the script needs to execute.

I won't cover the service principal creation process in this article. However, you can check this article section on creating a service principal from the Azure portal.

Use the following steps to log in to Azure CLI using Service Principal:

Before your login, you need three pieces of information for your login session.

  • Service principal Application (client) ID
  • Azure Tenant Name (Tenant Domain)
  • Service principal secret (create one)

You can find the Application ID on the Overview section of the page of your service principal when you create it for the first time:

The name of the tenant can be your FQDN that email accounts use in your tenant. If you don't have any custom domains configured, consider using the Microsoft provided domain.

  • Run the following command in your terminal:

Update the , , and with the relevant information to access your Azure tenant.

  • The results will confirm the successful login to your Azure account:

Working with Azure CLI Commands

Azure CLI has three main components: (a) Group, (b) Subgroup, and (c) Commands. Let's explore these more in-depth.

Each CLI command starts with initially. The is then followed by either a group or a subgroup or command.


A Group is referred to as the base command of . So, for example, if you refer to a virtual machine, the base command, in that case, would be VM. So, in simple words, the CLI commands are organized as groups.


A subgroup is a second layer under the group which comes into effect when a resource has more than one type or service. A subgroup may have further subgroups creating another level of hierarchy.

For example, there is SQL Server in Azure and also a SQL database. Similarly, Azure offers web applications as PaaS offerings. If you were to modify a website , it'd be a subgroup under that would allow you to interact with the configuration part of the resource.


The commands are the final action that you take on the cloud resource. The commands vary based on the resource you interact with. Refer to the commands available for a virtual machine resource that shows the possibility of action you can take on VM resource.

We'll cover how to see this information in the next sections.

Common Set of Resources

In Azure, while working on day-to-day tasks, you might come across one of these core services at some point. In addition, these offerings are some of the most popular services offered by Azure. So it's worth getting familiar with these resources.

Using Azure CLI Help with az help

If you've worked with any other programming or scripting frameworks, this may come off naturally to you. If not, that's fine either. Almost all the frameworks or CLI tools come with a command that gives you insights into using the tool and learning about basic usage examples.

While working with Azure CLI, the most helpful command is (help flag) while using any CLI command. This help flag displays the relevant information to either a group or a subgroup. In addition, it presents you with all the possible actions you can take to interact with any given resources.

For example, we'll look at Virtual Machine resources in Azure.

  • Run the following command inside your terminal. You don't need to be logged in to run this command.
  • The output will look like this:

The first thing to note here is the distribution of the output in , , and that we discussed earlier. Running the with a help flag displays the possible action you can take on the VM resource overall.

  • Let's take a look at subgroup command now. We'll be using the subgroup in this example. Run the following command in your terminal:
  • The output will look like this:

It's worth mentioning that the subgroup itself has a further subgroup that will display a distinct set of commands from the current query. The commands section shows all the possible actions you can take on the VM extensions at this point. We'll cover how to query at a later time.

  • Run the following query to check all the possible actions on the command:
  • The results will look like this:

While getting the help for the commands, you will see an and section that gives you the optional and required parameters to pass on while running the command.

For example, under the Arguments sections, you need to pass on the resource group's information and the VM name to interact with the resource to list all the extensions.

Feel free to play with other services and adding a help flag at the end to see the results for those commands.

Using Azure CLI Find Module

While working with a rich set of groups, subgroups, and commands, it's easier to get distracted and lose track of where to look for the information. Therefore, the Azure CLI offers another command that gives you the exact information on using any command with a set of examples.

The command displays a list of examples commands that you can run for any given service. Follow the steps below to explore Azure storage resource.

  • Run the following command in your terminal;
  • The output displays the common way in which you can use the storage resources:

It's worth mentioning that almost every query to Azure resource will need a specific name and resource group name, excluding the queries against all the resources such as the .

Using Azure CLI Query Module

The output of the Azure CLI command can get very lengthy based on the number of resources you query. That's why there's a better way to filter and display the necessary information only while working with CLI commands.

Follow the steps below to understand the different types of queries available on azure resources. It is recommended to deploy some resources inside your subscription to query against; otherwise, you'll be working with empty results.

  • Run the following command to query all the resources in Azure:
  • The output displays the list of resources as an array of JSON objects. In my case, the output looks like this:
  • The resource displayed in the output is a storage account used for Cloud Shell. Run the following command to query and filter the resources in the location :
  • The output again displays the same resource. However, the result is now much less than the number of entries earlier since you specified the location to query from in this case.

The query pattern () executes a JMESPath Query on the result of commands. JMESPath is a query language for JSON with the ability to select and modify the data for displaying simpler output results.

  • You can also display a limited set of output fields to clear the chaos in the output. Run the following output to display the , and fields of all the resources in the given location:
  • The output of the query is shown below in this case:

The output displays an array of JSON objects with the specific fields queried in the original command. You can use (dot) with to define the list of keys from the JSON object output. You can learn more about CLI Query here.

Working with Azure CLI Output Options

The result of Azure CLI is displayed in JSON format by convention. However, the CLI does support a variety of output formats that might be useful based on your use case. Below is a list of output that Azure CLI supports today:

The output format for the queries is defined by passing an output or flag at the end of the query.

  • Run the following command in your terminal to display the results from the previous command but with an output flag for table view:

The output display the data in a table format with the headings and data in rows.

  • Similarly, the following command displays the data as yaml output:

Setting up Azure CLI Default Configuration

While working with the CLI tool, you are always searching for consistency and ensuring your workspace stays the same any time you use, including any preferences you decide to configure. Luckily, Azure CLI allows you to configure logging, data collection, and default arguments for your terminal session using the command.

Configure Azure CLI Logging and Data Collection

Following the instructions below to configure your terminal for Azure CLI basic logging and data collection permissions:

  • Run the following command inside your terminal and enter y to confirm the action:
  • The default output for the CLI result is JSON. You can pick your desired output format that will be set to default for your session:
  • Set the optional logging for your terminal session:
  • Finally, choose to enable data collection for Azure CLI usage, if desired:
  • Leave the last prompt for cacheTTL as default and press Enter.

Configure CLI Default Configurations with az configure

While setting the configuration is pretty straightforward, you can also define your environment information for the terminal session and Azure CLI. Just as a reminder, you can always use the parameter to discover all the options for the command.

The CLI configuration allows you to predefine some of the commonly used environment settings for Azure resources, including the following:

  • Resource Group (group): The default resource group to use for all commands
  • Location (location): The default location to use for all commands
  • Web (webapp): The default App Service resource name to use
  • VM (vm): The default VM name to use
  • VMSS (vmss): The default VM Scale Set name to use
  • ACR (acr): The default container registry name to use

The configuration command takes one argument along with a pair separated by space. You can set the default using the following command:

You can find the full list of configuration values and environment variables on Microsoft Docs page.


You have configured your Azure CLI configuration and worked with various commands available to see how you can interact with Azure resources. In the next article, we'll go through creating your first Azure resource using Azure CLI.


Check out the previous post in the Azure CLI series:

Basics of Azure CLI



az account

Manage Azure subscription information.

az acr

Manage private registries with Azure Container Registries.

az ad

Manage Azure Active Directory Graph entities needed for Role Based Access Control.

az advisor

Manage Azure Advisor.

az aks

Manage Azure Kubernetes Services.

az apim

Manage Azure API Management services.

az appconfig

Manage App Configurations.

az appservice

Manage App Service plans.

az aro

Manage Azure Red Hat OpenShift clusters.

az artifacts

Manage Azure Artifacts.

az backup

Manage Azure Backups.

az batch

Manage Azure Batch.

az boards

Manage Azure Boards.

az cache

Commands to manage CLI objects cached using the argument.

az cloud

Manage registered Azure clouds.

az cognitiveservices

Manage Azure Cognitive Services accounts.

az config

Manage Azure CLI configuration.

az configure

Manage Azure CLI configuration. This command is interactive.

az cosmosdb

Manage Azure Cosmos DB database accounts.

az deployment

Manage Azure Resource Manager template deployment at subscription scope.

az deployment-scripts

Manage deployment scripts at subscription or resource group scope.

az deploymentmanager

Create and manage rollouts for your service.

az devops

Manage Azure DevOps organization level operations.

az disk

Manage Azure Managed Disks.

az disk-access

Manage disk access resources.

az disk-encryption-set

Disk Encryption Set resource.

az eventhubs

Manage Azure Event Hubs namespaces, eventhubs, consumergroups and geo recovery configurations - Alias.

az extension

Manage and update CLI extensions.

az feature

Manage resource provider features.

az feedback

Send feedback to the Azure CLI Team!

az find

I'm an AI robot, my advice is based on our Azure documentation as well as the usage patterns of Azure CLI and Azure ARM users. Using me improves Azure products and documentation.

az functionapp

Manage function apps. To install the Azure Functions Core tools see

az group

Manage resource groups and template deployments.

az hdinsight

Manage HDInsight resources.

az image

Manage custom virtual machine images.

az iot

Manage Internet of Things (IoT) assets.

az keyvault

Manage KeyVault keys, secrets, and certificates.

az kusto

Manage Azure Kusto resources.

az local-context

Manage Local Context.

az lock

Manage Azure locks.

az login

Log in to Azure.

az logout

Log out to remove access to Azure subscriptions.

az managedservices

Manage the registration assignments and definitions in Azure.

az monitor

Manage the Azure Monitor Service.

az mysql

Manage Azure Database for MySQL servers.

az netappfiles

Manage Azure NetApp Files (ANF) Resources.

az network

Manage Azure Network resources.

az openshift

Manage Azure Red Hat OpenShift Services.

az pipelines

Manage Azure Pipelines.

az policy

Manage resource policies.

az postgres

Manage Azure Database for PostgreSQL servers.

az ppg

Manage Proximity Placement Groups.

az provider

Manage resource providers.

az redis

Manage dedicated Redis caches for your Azure applications.

az relay

Manage Azure Relay Service namespaces, WCF relays, hybrid connections, and rules.

az repos

Manage Azure Repos.

az resource

Manage Azure resources.

az rest

Invoke a custom request.

az role

Manage user roles for access control with Azure Active Directory and service principals.

az search

Manage Azure Search services, admin keys and query keys.

az security

Manage your security posture with Azure Security Center.

az self-test

Runs a self-test of the CLI.

az servicebus

Manage Azure Service Bus namespaces, queues, topics, subscriptions, rules and geo-disaster recovery configuration alias.

az sf

Manage and administer Azure Service Fabric clusters.

az signalr

Manage Azure SignalR Service.

az snapshot

Manage point-in-time copies of managed disks, native blobs, or other snapshots.

az sql

Manage Azure SQL Databases and Data Warehouses.

az staticwebapp

Manage static apps.

az storage

Manage Azure Cloud Storage resources.

az synapse

Manage and operate Synapse Workspace, Spark Pool, SQL Pool.

az tag

Tag Management on a resource.

az upgrade

Upgrade Azure CLI and extensions.

az version

Show the versions of Azure CLI modules and extensions in JSON format by default or format configured by --output.

az vm

Manage Linux or Windows virtual machines.

az vmss

Manage groupings of virtual machines in an Azure Virtual Machine Scale Set (VMSS).

az webapp

Manage web apps.

Manage Azure CLI configuration. This command is interactive.


Set default resource group, webapp and VM names.

Clear default webapp and VM names.

Optional Parameters

--defaults -d

Space-separated 'name=value' pairs for common argument defaults.

--list-defaults -l

List all applicable defaults.

accepted values: false, true


Scope of defaults. Using "local" for settings only effective under current folder.

accepted values: global, local

default value: global

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

Send feedback to the Azure CLI Team!

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

I'm an AI robot, my advice is based on our Azure documentation as well as the usage patterns of Azure CLI and Azure ARM users. Using me improves Azure products and documentation.


Give me any Azure CLI group and I’ll show the most popular commands within the group.

Give me any Azure CLI command and I’ll show the most popular parameters and subcommands.

You can also enter a search term, and I'll try to help find the best commands.

Optional Parameters


An Azure CLI command or group for which you need an example.

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

Log in to Azure.


Log in interactively.

Log in with user name and password. This doesn't work with Microsoft accounts or accounts that have two-factor authentication enabled. Use -p=secret if the first character of the password is '-'.

Log in with a service principal using client secret. Use -p=secret if the first character of the password is '-'.

Log in with a service principal using client certificate.

Log in using a VM's system assigned identity

Log in using a VM's user assigned identity. Client or object ids of the service identity also work

Optional Parameters


Support access tenants without subscriptions. It's uncommon but useful to run tenant level commands, such as 'az ad'.

--identity -i

Log in using the Virtual Machine's identity.

--password -p

Credentials like user password, or for a service principal, provide client secret or a pem file with key and public certificate. Will prompt if not given.


The credential representing a service principal.

--tenant -t

The AAD tenant, must provide when using service principals.


Used with a service principal configured with Subject Name and Issuer Authentication in order to support automatic certificate rolls.


Use CLI's old authentication flow based on device code. CLI will also use this if it can't launch a browser in your behalf, e.g. in remote SSH or Cloud Shell.

--username -u

User name, service principal, or managed service identity ID.

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

Log out to remove access to Azure subscriptions.

Optional Parameters


Account user, if missing, logout the current active account.

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

az rest

Invoke a custom request.

This command automatically authenticates using the logged-in credential: If Authorization header is not set, it attaches header , where is retrieved from AAD. The target resource of the token is derived from --url if --url starts with an endpoint from . You may also use --resource for a custom resource. If Content-Type header is not set and --body is a valid JSON string, Content-Type header will default to application/json.


Get Audit log through Microsoft Graph

Update a Azure Active Directory Graph User's display name

Get a virtual machine

Create a public IP address from body.json file

List the top three resources (Bash)

Required Parameters

--uri --url -u

Request URL. If it doesn't start with a host, CLI assumes it as an Azure resource ID and prefixes it with the ARM endpoint of the current cloud shown by . Common token {subscriptionId} will be replaced with the current subscription ID specified by .

Optional Parameters

--body -b


Space-separated headers in KEY=VALUE format or JSON string. Use @{file} to load from a file.

--method -m

HTTP request method.

accepted values: delete, get, head, options, patch, post, put

default value: get


Save response payload to a file.


Resource url for which CLI should acquire a token from AAD in order to access the service. The token will be placed in the Authorization header. By default, CLI can figure this out based on --url argument, unless you use ones not in the list of "az cloud show --query endpoints".


Do not auto-append Authorization header.


Name or ID of subscription. You can configure the default subscription using .

--uri-parameters --url-parameters

Query parameters in the URL. Space-separated queries in KEY=VALUE format or JSON string. Use @{file} to load from a file.

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

az self-test

Runs a self-test of the CLI.

Optional Parameters


Name or ID of subscription. You can configure the default subscription using .

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

az upgrade

Upgrade Azure CLI and extensions.

Optional Parameters


Enable updating extensions as well.

accepted values: false, true

default value: true


Name or ID of subscription. You can configure the default subscription using .

--yes -y

Do not prompt for checking release notes.

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.

az version

Show the versions of Azure CLI modules and extensions in JSON format by default or format configured by --output.

Optional Parameters


Name or ID of subscription. You can configure the default subscription using .

Global Parameters


Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.


Only show errors, suppressing warnings.

--output -o



Increase logging verbosity. Use --debug for full debug logs.


Now discussing:

Such control. I easily plunged my cock into his ass, in one swift motion. Holding his thighs, I threw in long, deep blows, admiring the spectacle. I found it very easy to change the pace of the fuck.

856 857 858 859 860