适用于 Azure CLI 的 Azure Sphere 扩展概述

用于管理 Azure Sphere 附加设备和云部署的命令行工具作为 Azure CLI 扩展分发。

安装 Azure CLI 和 Azure Sphere 扩展

若要获取 Azure CLI 的 Azure Sphere 扩展,请执行以下操作:

  1. 安装 Azure CLI(如果尚未安装)。

  2. 若要添加 Azure Sphere 扩展,请运行以下命令:

    az extension add --name azure-sphere
    

必须使用 Azure CLI 登录 才能登录到要用于管理 Azure Sphere 设备的 Azure 订阅。

安装扩展后,会在 shell 变量的值 $AZURE_EXTENSION_DIR 下找到其位置。 如果未设置此变量,则默认情况下,该值 $HOME/.azure/cliextensions 在 Linux 和 macOS 上以及 %USERPROFILE%\.azure\cliextensions Windows 上为 。

提示

登录后,会看到与 Azure 帐户关联的订阅列表。 确保使用 命令选择具有所需权限的订阅, az account set 以便 Azure Sphere 扩展正常运行。 有关订阅选择的详细信息,请参阅 使用多个 Azure 订阅

管理 Azure Sphere 扩展

若要查看已安装的 Azure CLI 扩展版本,请使用 命令:

az version

若要将 Azure Sphere 扩展更新到最新版本,请使用:

az extension update --name azure-sphere

若要卸载 Azure Sphere 扩展,请使用:

az extension remove --name azure-sphere

常见的 Azure Sphere CLI 命令

可以通过在 Windows 命令提示符或 PowerShell 中键入内容 az sphere 来使用 Azure Sphere 命令。 在 Linux 上,可以使用任何命令行接口 (CLI) 。 CLI 具有 bash shell 下命令的完整选项卡补全功能。

下表列出了一些常见的 Azure Sphere 命令及其参考文档的链接。

命令 描述
az sphere catalog 管理目录。
az sphere ca-certificate 管理目录中的证书。
az sphere deployment 管理目录中的部署。
az sphere device 管理 Azure Sphere 设备。
az sphere device-group 管理目录中的设备组。
az sphere image 管理目录中的图像。
az sphere product 管理目录中的产品。
az sphere get-support-data 收集有关系统、云和设备配置的诊断数据。

Azure CLI 允许设置配置选项,通过提供 、 或 --catalog--resource-group--subscription参数的默认值来简化 Azure Sphere CLI 命令的使用。

设备依赖命令

命令适用于本地附加的 Azure Sphere 设备。 如果在未附加设备的情况下尝试命令,将收到错误。 有关设备命令的详细信息,请参阅 az sphere device

  • az sphere device claim
  • az sphere device recover
  • az sphere device restart
  • az sphere device show-attached
  • az sphere device show-os-version
  • az sphere device app show-memory-status
  • az sphere device app show-quota
  • az sphere device app show-status
  • az sphere device app start
  • az sphere device app stop
  • az sphere device capability show-attached
  • az sphere device capability update
  • az sphere device certificate add
  • az sphere device certificate delete
  • az sphere device certificate list
  • az sphere device certificate show
  • az sphere device certificate show-quota
  • az sphere device image list-installed
  • az sphere image-package show
  • az sphere device manufacturing-state show
  • az sphere device manufacturing-state update
  • az sphere device network proxy apply
  • az sphere device network proxy delete
  • az sphere device network proxy show
  • az sphere device network disable
  • az sphere device network enable
  • az sphere device network list-firewall-rules
  • az sphere device network list-interfaces
  • az sphere device network show-diagnostics
  • az sphere device network show-status
  • az sphere device network update-interface
  • az sphere device sideload delete
  • az sphere device sideload deploy
  • az sphere device wifi add
  • az sphere device wifi disable
  • az sphere device wifi enable
  • az sphere device wifi forget
  • az sphere device wifi list
  • az sphere device wifi reload-config
  • az sphere device wifi scan
  • az sphere device wifi show
  • az sphere device wifi show-status

全局可用参数

以下全局参数可用于 Azure Sphere 扩展:

参数 描述
--debug 增加日志记录详细程度以显示所有调试日志。
--help -h 显示帮助消息。
--only-show-errors 仅显示错误,禁止显示警告。
--output -o 输出格式。 允许的值:json、、jsoncnonetabletsvyaml、。 yamlc 默认值: json
--query JMESPath 查询字符串。 有关详细信息和示例,请参阅 http://jmespath.org/
--subscription :订阅的名称或 ID。 可以使用 配置默认订阅 az account set -s NAME_OR_ID
--verbose 增加日志记录详细程度。 用于 --debug 完整的调试日志。