Azure 球體 CLI 支援的輸出格式
Azure 球體 CLI 支援數種可檢視資料的格式。 根據預設,它做 table
為顯示 CLI 輸出的預設格式,但也支援其他格式。
注意
- 命令顯示的輸出可能會因不同輸出類型而異。
引數值和輸出類型為:
輸出格式 | 描述 |
---|---|
table |
含有索引鍵做為欄名的 ASCII 資料表。 這是預設格式。 |
json |
JSON 字串。 |
jsonc |
已著色 JSON。 |
yaml |
YAML,這是 JSON 的機器可讀替代方案。 |
yamlc |
已著色 YAML。 |
tsv |
索引標籤分隔值,沒有按鍵。 |
none |
除了錯誤和警告以外,沒有其他輸出。 |
支援的命令
您可以使用 --output
、 --out
或 -o
來指定命令的必要輸出格式。 如果我們缺少您需要腳本的命令,請透過 azsphere 意見反應讓我們知道。
下列命令支援:
- azsphere ca-certificate 清單
- azsphere ca-certificate 下載
- azsphere ca-certificate 下載鏈結
- azsphere ca-certificate download-proof
- azsphere 裝置應用程式顯示狀態
- azsphere 裝置 App show-memory-stats
- azsphere 裝置應用程式顯示配額
- azsphere 裝置應用程式啟動
- azsphere 裝置應用程式停止
- azsphere 裝置清單
- azsphere 裝置清單附加
- azsphere 裝置憑證新增
- azsphere 裝置憑證刪除
- azsphere 裝置憑證清單
- azsphere 裝置憑證顯示
- azsphere 裝置憑證顯示配額
- azsphere 裝置映射清單已安裝
- azsphere 裝置影像清單已設定目標
- azsphere 裝置網路啟用
- azsphere 裝置網路停用
- azsphere 裝置網路清單-防火牆規則
- azsphere 裝置網路清單介面
- 適用 azsphere 裝置網路 Proxy
- azsphere 裝置網路 Proxy 放映
- azsphere 裝置網路 Proxy 刪除
- azsphere 裝置網路顯示診斷
- azsphere 裝置網路顯示狀態
- azsphere 裝置網路更新介面
- azsphere 裝置重新連接
- azsphere 裝置重新開機
- azsphere 裝置放映
- azsphere 裝置顯示附加
- azsphere 裝置 show-os-version
- azsphere 裝置側載刪除
- azsphere 裝置側載部署
- azsphere 裝置側載 set-deployment-timeout
- azsphere 裝置側載 show-deployment-timeout
- azsphere 裝置 wifi 新增
- azsphere 裝置 wifi 停用
- azsphere 裝置 wifi 啟用
- azsphere 裝置 wifi 忘記
- azsphere 裝置 Wifi 清單
- azsphere 裝置 wifi 重載設定
- azsphere 裝置 wifi 掃描
- azsphere 裝置 wifi 放映
- azsphere 裝置 wifi 顯示狀態
- azsphere 裝置群組建立
- azsphere 裝置群組清單
- azsphere 裝置群組放映
- azsphere 裝置群組更新
- azsphere 裝置群組部署建立
- azsphere 裝置群組部署清單
- azsphere 裝置群組裝置清單
- azsphere 裝置群組裝置顯示計數
- azsphere 影像新增
- azsphere 影像下載
- azsphere 影像顯示
- azsphere 影像套件顯示
- azsphere 產品建立
- azsphere 產品清單
- azsphere 產品放映
- azsphere 產品更新
- azsphere 產品裝置清單
- azsphere 產品裝置顯示計數
- azsphere 產品裝置群組清單
- azsphere 產品裝置群組 create-defaults
- azsphere 角色清單
- azsphere 角色新增
- azsphere 角色刪除
- azsphere 角色顯示
- azsphere 角色顯示類型
- azsphere show-version
- azsphere show-user
- azsphere 設定清單
- azsphere 設定無色彩取得
- azsphere 設定無色彩集
- azsphere 租使用者建立
- azsphere 租使用者清單
- azsphere 租使用者選取
- azsphere 租使用者顯示選取
- azsphere 租使用者更新
表格輸出格式
此 table
格式是將輸出列印為 ASCII 表格的預設格式,可讓您輕鬆閱讀及掃描。 當您想要快速、人性化地搜尋資料概觀時,此格式是最佳作法。 取得焦點資訊的摘要很有用,尤其是清單命令。
azsphere tenant list --output table
------------------------------------ --------------------- -------------
Id Name Roles
========================================================================
143adbc9-1bf0-4be2-84a2-084a331d81cb MyTenant Contributor
------------------------------------ --------------------- -------------
768c2cd6-059a-49ad-9f53-89f5271cea15 MyTenant1 Administrator
Contributor
------------------------------------ --------------------- -------------
您可以使用參數 --query
來自訂您要在輸出中顯示的屬性和欄。 下列範例示範如何只選取清單命令中的 TenantID 和角色。
azsphere tenant list --query '[].{TenantID:id, Role:roles}'
------------------------------------ -------------
TenantID Role
==================================================
143adbc9-1bf0-4be2-84a2-084a331d81cb Contributor
------------------------------------ -------------
183adhc9-a5c8-8he2-84a2-c4f00f73a471 Administrator
Contributor
------------------------------------ -------------
注意
- 執行 JSON 格式的命令以檢視查詢中要使用的可用屬性名稱。 例如,當您執行
azsphere tenant list --output json
命令時,輸出會顯示該命令可用的名稱和值。 - 根據預設,巢狀物件、某些按鍵和欄位不會列印在資料表輸出中。 如果您需要在輸出中看到這些專案,可以使用 JMESPath 重新按鍵功能來變更金鑰名稱並避免篩選。 如需使用查詢來篩選資料的詳細資訊,請參閱 查詢 CLI 命令輸出。
JSON 輸出格式
JSON 輸出格式包含結構化格式的所有原始資料和巢狀資料。 我們建議您將 JSON 輸出用於精簡的輸出和腳本用途。 只有在命令成功並傳回 0 時,才適用此功能。
下列範例會以預設 JSON 格式顯示租使用者清單。
azsphere tenant list --output json
[
{
"id": "143adbc9-1bf0-4be2-84a2-084a331d81cb",
"name": "MyTenant",
"roles": [
"Contributor"
]
},
{
"id": "768c2cd6-059a-49ad-9f53-89f5271cea15",
"name": "MyTenant1",
"roles": [
"Administrator",
"Contributor"
]
}
]
YAML 輸出格式
此 yaml
格式會將輸出列印為 YAML,這是一種純文字資料序列化格式。 YAML 往往比 JSON 更容易閱讀。
azsphere tenant list --output yaml
- id: 143adbc9-1bf0-4be2-84a2-084a331d81cb
name: MyTenant
roles:
- Contributor
- id: 768c2cd6-059a-49ad-9f53-89f5271cea15
name: MyTenant1
roles:
- Administrator
- Contributor
TSV 輸出格式
輸出 tsv
格式會傳回定位點分隔值和新線分隔值,而不需要額外的格式設定、按鍵或其他符號。
輸出 tsv
結果與輸出類似, table
但不同之處如下:
- 欄標題不會顯示在輸出中
tsv
。 - 輸出會
table
顯示清單,並tsv
顯示清單的長度。 - 巢狀物件不會列印在輸出中
tsv
。 - 輸出
tsv
會分隔索引標籤,且無法配合終端機縮放。
azsphere tenant list --output tsv
143adbc9-1bf0-4be2-84a2-084a331d81cb MyTenant 1
768c2cd6-059a-49ad-9f53-89f5271cea15 MyTenant1 2