skip to Main Content

How to filter results using the OData filter on matching substrings?

$ az ad app list --help
...
Arguments:
    --filter                        : OData filter, e.g. --filter "displayname eq 'test' and
                                      servicePrincipalType eq 'Application'".

As per this documentation, I should be doable using for example contains function. I’m getting:

$ az ad app list --filter "contains(displayname, 'some-name')"                                                                                        
An unknown function with name 'contains' was found. This may also be a key lookup on a navigation property, which is not allowed.

2

Answers


  1. I am not sure why you are getting this error but when I ran the following command:

    az ad app list --filter "contains(displayname, 'some-name')"
    

    I got the following error:

    Unsupported property filter clause operator 'Contains'.
    

    which makes sense considering you cannot use contains function with displayName property. Functions supported for displayName property are: eq, ne, not, ge, le, in, startsWith, and eq on null values.

    Reference: https://learn.microsoft.com/en-us/graph/api/resources/application?view=graph-rest-1.0#properties.

    Login or Signup to reply.
  2. Maybe az rest with $search could help. The following command returns the applications when display name contains word demo:

    az rest --method get --uri 'https://graph.microsoft.com/v1.0/applications?$search="displayname:demo"' --headers ConsistencyLevel=Eventual
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search