添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft Edge More info about Internet Explorer and Microsoft Edge

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 bash 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 az --version .

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 .

  • Run the login command.

    az login
    

    If the CLI can open your default browser, it initiates authorization code flow and open the default browser to load an Azure sign-in page.

    Otherwise, it initiates the device code flow and tell you to open a browser page at https://aka.ms/devicelogin and enter the code displayed in your terminal.

    If no web browser is available or the web browser fails to open, you may force device code flow with az login --use-device-code.

  • Sign in with your account credentials in the browser.

    After logging in, you see a list of subscriptions associated with your Azure account. The subscription information with isDefault: true 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.

    Resource type Azure CLI command group

    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 secret, use the following command:

    az find secret
    

    Use the --help 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):

    az network nsg --help
    

    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.

  • --help prints CLI reference information about commands and their arguments and lists available subgroups and commands.
  • --output changes the output format. The available output formats are json, jsonc (colorized JSON), tsv (Tab-Separated Values), table (human-readable ASCII tables), and yaml. By default the CLI outputs json. To learn more about the available output formats, see Output formats for Azure CLI.
  • --query 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.
  • --verbose prints information about resources created in Azure during an operation, and other useful information.
  • --debug prints even more information about CLI operations, used for debugging purposes. If you find a bug, provide output generated with the --debug 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.

    az interactive
    

    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.

    Create virtual machines with the Azure CLI tutorial

    There are also Quickstarts for other popular services.

  • Create a storage account using the Azure CLI
  • Transfer objects to/from Azure Blob storage using the CLI
  • Create a single Azure SQL database using the Azure CLI
  • Create an Azure Database for MySQL server using the Azure CLI
  • Create an Azure Database for PostgreSQL using the Azure CLI
  • Create a Python web app in Azure
  • Run a custom Docker Hub image in Azure Web Apps for Containers
  • 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.

    az feedback
    

    See also

  • Onboarding cheat sheet
  • Learn to use Bash with the Azure CLI
  • Full command reference list for the Azure CLI
  •