I am query for resources in a subscription as follows:
(az resource list --subscription <subscription-id> --query "[?
type=='Microsoft.Web/sites'] "| ConvertFrom-Json)
But i want to put a second query parameter like the following
(az resource list --subscription <subscription-id> --query "[?
type=='Microsoft.Web/sites'&& resourcegroup== $resourcegroup.name ]"|
ConvertFrom-Json)
How can i do this ?
2
Answers
Please try by using the
Pipe expression
(|
) to separate each condition. Your command would be something like:Please ensure that you are using proper casing for property names (e.g.
resourceGroup
instead ofresourcegroup
) and string values are inside single quotes.Here’s the command I used to get storage accounts in a resource group in my Azure Subscription:
For querying multiple parameters you can use az graph query in azure cli as below and I followed Microsoft-Document:
Firstly, Set account subscription as below:
XX- Subscription name.
Now query to get resources: