Azure Developer CLI 参考

本文介绍各种 Azure 开发人员 CLI 命令的语法和参数。

azd

Azure 开发人员 CLI (azd) 是一种开源工具,可帮助在 Azure 上载入和管理应用程序

选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --docs         Opens the documentation for azd in your web browser.
  -h, --help         Gets help for azd.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

  • azd auth:使用 Azure 进行身份验证。
  • azd config:管理 azd configurations(例如:默认 Azure 订阅,位置)。
  • azd deploy:将应用程序的代码部署到 Azure。
  • azd down:删除应用程序的 Azure 资源。
  • azd env:管理环境。
  • azd hooks:为应用程序开发、测试和运行挂钩。 (Beta)
  • azd init:初始化新应用程序。
  • azd monitor:监视已部署的应用程序。 (Beta)
  • azd package:打包要部署到 Azure 的应用程序代码。 (Beta)
  • azd pipeline:管理和配置部署管道。 (Beta)
  • azd provision:为应用程序预配 Azure 资源。
  • azd restore:还原应用程序的依赖项。 (Beta)
  • azd show:显示有关应用及其资源的信息。
  • azd template:查找和查看模板详细信息。 (Beta)
  • azd up:预配 Azure 资源,并使用单个命令部署项目。
  • azd version:打印 Azure 开发人员 CLI 的版本号。

azd auth

使用 Azure 进行身份验证。

选项

      --docs   Opens the documentation for azd auth in your web browser.
  -h, --help   Gets help for auth.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd auth login

登录到 Azure。

摘要

登录到 Azure。

在没有任何参数的情况下运行时,请使用浏览器以交互方式登录。 若要使用设备代码登录,请传递 --use-device-code。

若要以服务主体身份登录,请传递 --client-id 和 --tenant-id 以及以下项之一:--client-secret、--client-certificate 或 --federated-credential-provider。

azd auth login [flags]

选项

      --check-status                           Checks the log-in status instead of logging in.
      --client-certificate string              The path to the client certificate for the service principal to authenticate with.
      --client-id string                       The client id for the service principal to authenticate with.
      --client-secret string                   The client secret for the service principal to authenticate with. Set to the empty string to read the value from the console.
      --docs                                   Opens the documentation for azd auth login in your web browser.
      --federated-credential-provider string   The provider to use to acquire a federated token to authenticate with.
  -h, --help                                   Gets help for login.
      --redirect-port int                      Choose the port to be used as part of the redirect URI during interactive login.
      --tenant-id string                       The tenant id or domain name to authenticate with.
      --use-device-code[=true]                 When true, log in by using a device code instead of a browser.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd auth logout

从 Azure 注销。

摘要

注销 Azure

azd auth logout [flags]

选项

      --docs   Opens the documentation for azd auth logout in your web browser.
  -h, --help   Gets help for logout.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config

管理 azd 配置(例如:默认 Azure 订阅,位置)。

摘要

管理 Azure 开发人员 CLI 用户配置,其中包括默认的 Azure 订阅和位置。

azure-dev-cli_0.4.0-beta.1 起可用。

首次配置 azd 的最简单方法是运行 azd init。 所选的订阅和位置将存储在 config.json 位于配置目录中的文件中。 若要以后随时进行配置 azd ,你将使用 azd config set

配置目录的默认值为:

  • linux 和 macOS 上的 $HOME/.azd
  • %U标准版 Windows 上的RPROFILE%.azd

可以通过在AZD_CONFIG_DIR环境变量中指定路径来重写配置目录。

选项

      --docs   Opens the documentation for azd config in your web browser.
  -h, --help   Gets help for config.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config get

获取配置。

摘要

获取配置路径中的配置。

配置目录的默认值为:

  • $HOME/.azd 在 Linux 和 macOS 上
  • 在 Windows 上为 %USERPROFILE%\.azd

可以通过在AZD_CONFIG_DIR环境变量中指定路径来重写配置目录。

azd config get <path> [flags]

选项

      --docs   Opens the documentation for azd config get in your web browser.
  -h, --help   Gets help for get.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config list-alpha

在 alpha 阶段显示可用功能的列表。

azd config list-alpha [flags]

选项

      --docs   Opens the documentation for azd config list-alpha in your web browser.
  -h, --help   Gets help for list-alpha.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config reset

将配置重置为默认值。

摘要

重置配置路径中的所有配置。

配置目录的默认值为:

  • $HOME/.azd 在 Linux 和 macOS 上
  • 在 Windows 上为 %USERPROFILE%\.azd

可以通过将AZD_CONFIG_DIR环境变量中的路径指定为默认值来重写配置目录。

azd config reset [flags]

选项

      --docs    Opens the documentation for azd config reset in your web browser.
  -f, --force   Force reset without confirmation.
  -h, --help    Gets help for reset.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config set

设置配置。

摘要

在配置路径中设置配置。

配置目录的默认值为:

  • $HOME/.azd 在 Linux 和 macOS 上
  • 在 Windows 上为 %USERPROFILE%\.azd

可以通过在AZD_CONFIG_DIR环境变量中指定路径来重写配置目录。

azd config set <path> <value> [flags]

示例

azd config set defaults.subscription <yourSubscriptionID>
azd config set defaults.location eastus

选项

      --docs   Opens the documentation for azd config set in your web browser.
  -h, --help   Gets help for set.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config show

显示所有配置值。

摘要

显示配置路径中的所有配置值。

配置目录的默认值为:

  • $HOME/.azd 在 Linux 和 macOS 上
  • 在 Windows 上为 %USERPROFILE%\.azd

可以通过在AZD_CONFIG_DIR环境变量中指定路径来重写配置目录。

azd config show [flags]

选项

      --docs   Opens the documentation for azd config show in your web browser.
  -h, --help   Gets help for show.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd config unset

取消设置配置。

摘要

删除配置路径中的配置。

配置目录的默认值为:

  • $HOME/.azd 在 Linux 和 macOS 上
  • 在 Windows 上为 %USERPROFILE%\.azd

可以通过在AZD_CONFIG_DIR环境变量中指定路径来重写配置目录。

azd config unset <path> [flags]

示例

azd config unset defaults.location

选项

      --docs   Opens the documentation for azd config unset in your web browser.
  -h, --help   Gets help for unset.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd deploy

将应用程序的代码部署到 Azure。

azd deploy <service> [flags]

选项

      --all                   Deploys all services that are listed in azure.yaml
      --docs                  Opens the documentation for azd deploy in your web browser.
  -e, --environment string    The name of the environment to use.
      --from-package string   Deploys the application from an existing package.
  -h, --help                  Gets help for deploy.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd down

删除应用程序的 Azure 资源。

azd down [flags]

选项

      --docs                 Opens the documentation for azd down in your web browser.
  -e, --environment string   The name of the environment to use.
      --force                Does not require confirmation before it deletes resources.
  -h, --help                 Gets help for down.
      --purge                Does not require confirmation before it permanently deletes resources that are soft-deleted by default (for example, key vaults).

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env

管理环境。

选项

      --docs   Opens the documentation for azd env in your web browser.
  -h, --help   Gets help for env.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env get-values

获取所有环境值。

azd env get-values [flags]

选项

      --docs                 Opens the documentation for azd env get-values in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for get-values.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env list

列出环境。

azd env list [flags]

选项

      --docs   Opens the documentation for azd env list in your web browser.
  -h, --help   Gets help for list.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env new

创建新环境并将其设置为默认值。

azd env new <environment> [flags]

选项

      --docs                  Opens the documentation for azd env new in your web browser.
  -h, --help                  Gets help for new.
  -l, --location string       Azure location for the new environment
      --subscription string   Name or ID of an Azure subscription to use for the new environment

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env refresh

使用先前基础结构预配中的信息刷新环境设置。

azd env refresh <environment> [flags]

选项

      --docs                 Opens the documentation for azd env refresh in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for refresh.
      --hint string          Hint to help identify the environment to refresh

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env select

设置默认环境。

azd env select <environment> [flags]

选项

      --docs   Opens the documentation for azd env select in your web browser.
  -h, --help   Gets help for select.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd env set

管理环境设置。

azd env set <key> <value> [flags]

选项

      --docs                 Opens the documentation for azd env set in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for set.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd hooks

为应用程序开发、测试和运行挂钩。 (Beta)

选项

      --docs   Opens the documentation for azd hooks in your web browser.
  -h, --help   Gets help for hooks.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd hooks run

为项目和服务运行指定的挂钩

azd hooks run <name> [flags]

选项

      --docs                 Opens the documentation for azd hooks run in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for run.
      --platform string      Forces hooks to run for the specified platform.
      --service string       Only runs hooks for the specified service.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd init

初始化新应用程序。

azd init [flags]

选项

  -b, --branch string         The template branch to initialize from. Must be used with a template argument (--template or -t).
      --docs                  Opens the documentation for azd init in your web browser.
  -e, --environment string    The name of the environment to use.
  -h, --help                  Gets help for init.
  -l, --location string       Azure location for the new environment
  -s, --subscription string   Name or ID of an Azure subscription to use for the new environment
  -t, --template string       The template to use when you initialize the project. You can use Full URI, <owner>/<repository>, or <repository> if it's part of the azure-samples organization.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd monitor

监视已部署的应用程序。 (Beta)

azd monitor [flags]

选项

      --docs                 Opens the documentation for azd monitor in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for monitor.
      --live                 Open a browser to Application Insights Live Metrics. Live Metrics is currently not supported for Python apps.
      --logs                 Open a browser to Application Insights Logs.
      --overview             Open a browser to Application Insights Overview Dashboard.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd package

打包要部署到 Azure 的应用程序代码。 (Beta)

azd package <service> [flags]

选项

      --all                  Packages all services that are listed in azure.yaml
      --docs                 Opens the documentation for azd package in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for package.
      --output-path string   File or folder path where the generated packages will be saved.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd pipeline

管理和配置部署管道。 (Beta)

选项

      --docs   Opens the documentation for azd pipeline in your web browser.
  -h, --help   Gets help for pipeline.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd pipeline config

配置部署管道以安全地连接到 Azure。 (Beta)

azd pipeline config [flags]

选项

      --auth-type string             The authentication type used between the pipeline provider and Azure for deployment (Only valid for GitHub provider). Valid values: federated, client-credentials.
      --docs                         Opens the documentation for azd pipeline config in your web browser.
  -e, --environment string           The name of the environment to use.
  -h, --help                         Gets help for config.
      --principal-id string          The client id of the service principal to use to grant access to Azure resources as part of the pipeline.
      --principal-name string        The name of the service principal to use to grant access to Azure resources as part of the pipeline.
      --principal-role stringArray   The roles to assign to the service principal. By default the service principal will be granted the Contributor and User Access Administrator roles. (default [Contributor,User Access Administrator])
      --provider string              The pipeline provider to use (github for Github Actions and azdo for Azure Pipelines).
      --remote-name string           The name of the git remote to configure the pipeline to run on. (default "origin")

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd provision

为应用程序预配 Azure 资源。

azd provision [flags]

选项

      --docs                 Opens the documentation for azd provision in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for provision.
      --no-state             Do not use latest Deployment State (bicep only).
      --preview              Preview changes to Azure resources.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd restore

还原应用程序的依赖项。 (Beta)

azd restore <service> [flags]

选项

      --all                  Restores all services that are listed in azure.yaml
      --docs                 Opens the documentation for azd restore in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for restore.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd show

显示有关应用及其资源的信息。

azd show [flags]

选项

      --docs                 Opens the documentation for azd show in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for show.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template

查找和查看模板详细信息。 (Beta)

选项

      --docs   Opens the documentation for azd template in your web browser.
  -h, --help   Gets help for template.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template list

显示示例 azd 模板的列表。 (Beta)

azd template list [flags]

选项

      --docs            Opens the documentation for azd template list in your web browser.
  -h, --help            Gets help for list.
  -s, --source string   Filters templates by source.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template show

显示给定模板的详细信息。 (Beta)

azd template show <template> [flags]

选项

      --docs   Opens the documentation for azd template show in your web browser.
  -h, --help   Gets help for show.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template source

查看和管理模板源。 (Beta)

选项

      --docs   Opens the documentation for azd template source in your web browser.
  -h, --help   Gets help for source.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template source add

在指定的密钥处添加 azd 模板源 (Beta)

azd template source add <key> [flags]

选项

      --docs              Opens the documentation for azd template source add in your web browser.
  -h, --help              Gets help for add.
  -l, --location string   Location of the template source.
  -n, --name string       Display name of the template source.
  -t, --type string       Kind of the template source.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template source list

列出配置的 azd 模板源。 (Beta)

azd template source list [flags]

选项

      --docs   Opens the documentation for azd template source list in your web browser.
  -h, --help   Gets help for list.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd template source remove

删除指定的 azd 模板源 (Beta)

azd template source remove <key> [flags]

选项

      --docs   Opens the documentation for azd template source remove in your web browser.
  -h, --help   Gets help for remove.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd up

预配 Azure 资源,并使用单个命令部署项目。

azd up [flags]

选项

      --docs                 Opens the documentation for azd up in your web browser.
  -e, --environment string   The name of the environment to use.
  -h, --help                 Gets help for up.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅

azd version

打印 Azure 开发人员 CLI 的版本号。

azd version [flags]

选项

      --docs   Opens the documentation for azd version in your web browser.
  -h, --help   Gets help for version.

从父命令继承的选项

  -C, --cwd string   Sets the current working directory.
      --debug        Enables debugging and diagnostics logging.
      --no-prompt    Accepts the default value instead of prompting, or it fails if there is no default.

另请参阅