az graph
備註
此參考是 Azure CLI 的 資源圖形 延伸模組的一部分(2.22.0 版或更高版本)。 擴充功能會在您第一次執行 az graph 命令時自動安裝。 深入瞭解擴充功能。
查詢 Azure Resource Manager 所管理的資源。
執行 『az graph query --help』 以取得詳細說明。
命令
名稱 | Description | 類型 | 狀態 |
---|---|---|---|
az graph query |
查詢 Azure Resource Manager 所管理的資源。 |
擴充套件 | GA |
az graph shared-query |
管理 Azure 資源圖表的共享查詢。 |
擴充套件 | 實驗性的 |
az graph shared-query create |
建立共享查詢。 |
擴充套件 | 實驗性的 |
az graph shared-query delete |
刪除共享查詢。 |
擴充套件 | 實驗性的 |
az graph shared-query list |
列出資源群組中的所有共享查詢。 |
擴充套件 | 實驗性的 |
az graph shared-query show |
顯示共用查詢的屬性。 |
擴充套件 | 實驗性的 |
az graph query
查詢 Azure Resource Manager 所管理的資源。
若要深入瞭解查詢語言和流覽範例,請參閱 https://aka.ms/AzureResourceGraph-QueryLanguage。
az graph query --graph-query --q
[--allow-partial-scopes {false, true}]
[--first]
[--management-groups]
[--skip]
[--skip-token]
[--subscriptions]
範例
查詢要求資源字段子集的資源。
az graph query -q "project id, name, type, location, tags"
使用欄位選取、篩選和摘要查詢資源。
az graph query -q "project id, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"
要求結果的子集,略過20個專案並取得下一個10個專案。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --first 10 --skip 20
選擇要查詢的訂用帳戶。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --subscriptions 11111111-1111-1111-1111-111111111111 22222222-2222-2222-2222-222222222222
選擇要查詢的管理群組。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --management-groups aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb --allow-partial-scopes
使用略過令牌進行查詢。
az graph query -q "where type =~ "Microsoft.Compute" | project name, tags" --skip-token skip_token_value_from_previous_query_response
必要參數
要執行的 Resource Graph 查詢。
選擇性參數
指出當伺服器只能處理下方部分訂用帳戶數目時,查詢是否應該成功。
要傳回的物件數目上限。 接受的範圍:1-1000。
要執行查詢的管理群組清單。
忽略第一個 N 物件,然後取得其餘的物件。
如果適用的話,請略過令牌以取得查詢的下一頁。
要執行查詢的訂用帳戶清單。 默認會查詢所有可存取的訂用帳戶。
全域參數
提高日誌詳細程度以顯示所有調試日誌。
顯示此說明訊息並結束。
只顯示錯誤,隱藏警告。
輸出格式。
JMESPath 查詢字串。 如需詳細資訊和範例,請參閱 http://jmespath.org/。
訂用帳戶的名稱或標識碼。 您可以使用 az account set -s NAME_OR_ID
來設定預設訂用帳戶。
增加記錄的詳細程度。 針對完整偵錯記錄使用 --debug。