Repository navigation
Where to find OData supported query operators in --filter parameter #14277
Description
Activity
- ghost addedneeds-triageThis is a new issue that needs to be triaged to the appropriate team.This is a new issue that needs to be triaged to the appropriate team.
on Jul 8, 2020 - ghost addedquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
on Jul 8, 2020 - ghost removedneeds-triageThis is a new issue that needs to be triaged to the appropriate team.This is a new issue that needs to be triaged to the appropriate team.
on Jul 8, 2020 - addedGraph(doesn't work with label-triggered comments; use Graph.Microsoft instead) az ad(doesn't work with label-triggered comments; use Graph.Microsoft instead) az adand removedquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as thatThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
on Jul 8, 2020 add to S173
- addedOutput QueryJMESPath query issues for Azure CLI outputJMESPath query issues for Azure CLI output
on Aug 17, 2020 14 remaining items
The
az ad app list --filter "startswith(displayName,'myAppRegistration')"
from the issue description does not work anymore, it says "Invalid filter clause". This is now the same as endswith.There was an underlying API change in Azure CLI version 2.37.0:
The underlying Active Directory Graph API will be replaced by Microsoft Graph API in Azure CLI 2.37.0. Please carefully review all breaking changes introduced during this migration: https://docs.microsoft.com/cli/azure/microsoft-graph-migration
I updated my CLI version (I was still in version 2.36.0). Now with version 2.45.0 I also have the error "Invalid filter clause" with the command
az ad app list --filter "startswith(displayName,'myAppRegistration')"Startswith seems supported by Microsoft Graph API (doc). I don't know how Azure CLI will handle the syntax.
I tried this PowerShell code and it works:
Get-MgApplication -Filter "startswith(displayName, 'myAppRegistration')" -CountVariable CountVar -Top 10 -Sort "displayName" -ConsistencyLevel eventual
I have read in the Graph API reference where I also got this code from that filters and orderby in conjunction with app registrations work only when you also have the CountVariable and the ConsistencyLevel eventual.Reacted by GismorkWill endswith be supported in bash?
Similar question about Powershell and Az.Resources 7.9.0
Only a basic
eqworks:Get-AzResource -ResourceGroupName $rgname -ODataQuery "`$filter=resourceType eq 'Microsoft.Network/networkInterfaces'"These two fail, though with different exceptions (I get a
DetailselemenGet-AzResource -ResourceGroupName $rgname -ODataQuery "`$filter=startswith(resourceType,'Microsoft.Network/networkInterfaces')" Get-AzResource: Invalid $filter 'startswith(resourceType,'Microsoft.Network/networkInterfaces')' specified in the query string. Details: 'Unsupported filter function found:'startswith'. Property name:'resourcetype'. Supported functions: ''''' StatusCode: 400 ReasonPhrase: Bad RequestGet-AzResource -ResourceGroupName $rgname -ODataQuery "`$filter=contains(resourceType,'Microsoft.Network/networkInterfaces')" Get-AzResource: Invalid $filter 'contains(resourceType,'Microsoft.Network/networkInterfaces')' specified in the query string. StatusCode: 400 ReasonPhrase: Bad RequestUpdate on current CLI (2.87.0):
startswith works again. The 2023 "Invalid filter clause" regression is resolved.
endswith needs Microsoft Graph advanced query (the ConsistencyLevel: eventual header plus $count=true), which az ad list commands don't send. It now fails with a clear error saying exactly that, instead of the old cryptic one.
Workaround today, using your existing az login:az rest --method get --url "https://graph.microsoft.com/v1.0/applications?$filter=endswith(displayName,'a')&$count=true" --headers "ConsistencyLevel=eventual"
Operator support per resource: https://learn.microsoft.com/en-us/graph/aad-advanced-queries
Closing as the questions here are addressed. Native advanced-query support in az ad --filter would be a separate enhancement, feel free to open a focused issue if that would help.
hkelley that one is a different stack. Get-AzResource -ODataQuery goes through Azure Resource Manager (the /resources endpoint), not Microsoft Graph, so the ConsistencyLevel: eventual advanced-query approach above does not apply here.
ARM's resource $filter supports only a limited set of operators (as your error shows), which is separate from the az ad / Graph behavior in this issue.
Could you open a fresh issue in the Azure PowerShell repo (https://github.com/Azure/azure-powershell) if you still need help.
Hi,
In several Azure CLI commands, you can use a
--filterparameter to use OData syntax to filter your query.It's seems that all OData operators aren't supported.
You can do:
az ad app list --filter "displayName eq 'myAppRegistrationDisplayNameHere'"Or:
az ad app list --filter "startswith(displayName,'myAppRegistration')"But you can't use endswith;
az ad app list --filter "endswith(displayName,'appRegistrationEnd')"You get an error:
Unsupported QueryI didn't find any documentation listing this information.
Is there a documentation somewhere that list all supported OData operators when using Azure CLI
--filterparameter ?Thank you
PS: Using Azure CLI 2.8.0
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.