您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure 命令行界面 (CLI)Azure Command-Line Interface (CLI)

Azure 命令行接口 (CLI) 是用于管理 Azure 资源的 Microsoft 跨平台命令行体验。The Azure command-line interface (CLI) is Microsoft's cross-platform command-line experience for managing Azure resources. 可以通过 Azure Cloud Shell 在浏览器中使用它,也可以将其安装在 macOS、Linux 或 Windows 上,然后从命令行运行它。Use it in your browser with Azure Cloud Shell, or install it on macOS, Linux, or Windows and run it from the command line.

Azure CLI 易于入门,非常适合用于生成可与 Azure 资源管理器配合使用的自动化脚本。The Azure CLI is easy to get started with, and best used for building automation scripts that work with the Azure Resource Manager. 使用 Azure CLI 时,只需键入以下命令,即可在 Azure 中轻松创建 VM:Using the Azure CLI, you can create VMs within Azure as easily as typing the following command:

az vm create -n MyLinuxVM -g MyResourceGroup --image UbuntuLTS

备注

在脚本和 Microsoft 文档网站中,已针对 bash shell 编写了 Azure CLI 示例。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. 包括续行符 (\) 或变量赋值的更长示例需要修改才能在其他 shell(包括 PowerShell)上工作。Longer examples which include line continuations (\) or variable assignment need to be modified to work on other shells, including PowerShell.

运行或安装Run or Install

可在本地安装 CLI,在浏览器中使用 Azure Cloud Shell 运行 CLI,或者在 Docker 容器中运行 CLI。You can install the CLI locally, run it in the browser with Azure Cloud Shell, or run in a Docker container. 若要获取 CLI 的当前版本,请运行 az --versionTo get the current version of the CLI, run az --version.

利用 Microsoft Learn 掌握技能Build your skills with Microsoft Learn

入门Get started

请阅读入门一文来了解 CLI 基础知识。Read the Get Started article to learn the CLI basics. 以下示例演示一些常见用例:The following samples demonstrate some common uses cases:

我们还提供了一篇详细的参考文章,其中介绍了如何使用每个 Azure CLI 命令。A detailed reference is also available that documents how to use each individual Azure CLI command.

备注

如果正在使用旧版 CLI(Azure 经典 CLI),可以继续使用它。If you use the previous version of the CLI (Azure classic CLI), you can continue to use it. 但是,建议进行更新以使用最新版本的 Azure CLI 来获得最佳体验。However, we recommend updating to use the latest version of the Azure CLI for the best experience. 如果同时使用这两个版本的 CLI,请记住,azure 是经典 CLI,az 是最新 CLI。If you use both CLIs, remember that azure is the classic CLI and that az is the most recent CLI.