我正在查詢訂閱中的資源,如下所示:
(az resource list --subscription <subscription-id> --query "[?
type=='Microsoft.Web/sites'] "| ConvertFrom-Json)
但我想放置第二個查詢引數,如下所示
(az resource list --subscription <subscription-id> --query "[?
type=='Microsoft.Web/sites'&& resourcegroup== $resourcegroup.name ]"|
ConvertFrom-Json)
我怎樣才能做到這一點 ?
uj5u.com熱心網友回復:
要查詢多個引數,您可以在 azure cli 中使用 az graph query,如下所示,我遵循Microsoft-Document:
首先,設定帳戶訂閱如下:
az account set --name "XX"
XX-訂閱名稱。
現在查詢以獲取資源:
az graph query -q "Resources | where type=~ 'microsoft.web/sites' | project resourceGroup, name"| ConvertFrom-Json

uj5u.com熱心網友回復:
請嘗試使用Pipe expression( |) 分隔每個條件。您的命令將類似于:
(az resource list --subscription <subscription-id> --query "[?
type=='Microsoft.Web/sites'] | [?resourceGroup=='$resourcegroup.name']" |
ConvertFrom-Json)
請確保您為屬性名稱使用了正確的大小寫(例如resourceGroup,而不是resourcegroup),并且字串值在單引號內。
這是我用來在 Azure 訂閱中的資源組中獲取存盤帳戶的命令:
az resource list --query "[? type=='Microsoft.Storage/storageAccounts'] | [?resourceGroup=='my-resource-group-name']"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/516710.html
標籤:天蓝色电源外壳
