用來管理 Azure Sphere 連結裝置和雲端部署的命令行工具會以 Azure CLI 擴充功能的形式散發。
安裝 Azure CLI 和 Azure Sphere 擴充功能
若要取得 Azure CLI 的 Azure Sphere 擴充功能:
若要新增 Azure Sphere 擴充功能,請執行下列命令:
az extension add --name azure-sphere
您必須 使用 Azure CLI 登入,才能登入您想要用來管理 Azure Sphere 裝置的 Azure 訂用帳戶。
安裝擴充功能之後,其位置就會在殼層變數的值 $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)。 針對 bash 殼層下的命令,CLI 有完整的 tab 鍵自動完成。
下表列出一些常見的 Azure Sphere 命令,以及其參考文件的連結。
| Command | 描述 |
|---|---|
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等參數的預設值,以簡化 Azure Sphere CLI 命令的使用--resource-group--subscription。
裝置相依命令
此命令適用於本機連結的 Azure Sphere 裝置。 如果您嘗試命令但未連結裝置,您會收到錯誤。 如需裝置命令的詳細資訊, 請參閱 az sphere device
az sphere device claimaz sphere device recoveraz sphere device restartaz sphere device show-attachedaz sphere device show-os-versionaz sphere device app show-memory-statusaz sphere device app show-quotaaz sphere device app show-statusaz sphere device app startaz sphere device app stopaz sphere device capability show-attachedaz sphere device capability updateaz sphere device certificate addaz sphere device certificate deleteaz sphere device certificate listaz sphere device certificate showaz sphere device certificate show-quotaaz sphere device image list-installedaz sphere image-package showaz sphere device manufacturing-state showaz sphere device manufacturing-state updateaz sphere device network proxy applyaz sphere device network proxy deleteaz sphere device network proxy showaz sphere device network disableaz sphere device network enableaz sphere device network list-firewall-rulesaz sphere device network list-interfacesaz sphere device network show-diagnosticsaz sphere device network show-statusaz sphere device network update-interfaceaz sphere device sideload deleteaz sphere device sideload deployaz sphere device wifi addaz sphere device wifi disableaz sphere device wifi enableaz sphere device wifi forgetaz sphere device wifi listaz sphere device wifi reload-configaz sphere device wifi scanaz sphere device wifi showaz sphere device wifi show-status
全域可用的自變數
Azure Sphere 擴充功能提供下列全域參數:
| 參數 | 描述 |
|---|---|
--debug |
增加記錄詳細資訊,以顯示所有偵錯記錄。 |
--help -h |
顯示說明訊息。 |
--only-show-errors |
只顯示錯誤,隱藏警告。 |
--output -o |
輸出格式。 允許的值:json、、、jsonc、nonetable、tsv、yamlcyaml。 預設值:json。 |
--query |
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。 |
--subscription |
:訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID 設定預設訂用帳戶。 |
--verbose |
增加記錄詳細資訊。 使用 --debug 以取得完整的偵錯記錄。 |