What are the supported filter operations on Azure Resource Group list

213 views Asked by At

I'm trying to find a resource group that has a partial name match.

I'm trying something like: https://management.azure.com/subscriptions/<sub ID>/resourcegroups?api-version=2020-10-01&%24filter=substringof(Name%2C%20'<something>')

but I keep getting:

{
  "error": {
    "code": "InvalidFilterInQueryString",
    "message": "Invalid $filter 'substringof(Name, '<something>')' specified in the query string."
  }
}

I've been trying it out here: https://learn.microsoft.com/en-us/rest/api/resources/resource-groups/list#code-try-0

But sadly cannot find the list of filters that I can use in this rest call. All of the string ones from here don't seem to work: https://learn.microsoft.com/en-us/dynamics-nav/using-filter-expressions-in-odata-uris

Does anyone know where to find the list?

1

There are 1 answers

1
Daredevil On

Azure Resource Manager (ARM) does not support the substringof function in the $filter query for resource groups.

If you need to filter resource groups by a partial name match, you can have retrieve all resource groups and then filter them client-side.

  1. Retrieve All Resource Groups:

    For example, using Azure CLI:

    az group list --output json
    
  2. Filter Client-Side: using the Azure CLI and jq (a lightweight and flexible command-line JSON processor), you can:

    az group list --output json | jq '.[] | select(.name | contains("<something>"))'