Reputation: 41
Although I'm new to JMESPath, but even so, feeling extra dumbfounded that none of the docs I've pulled have a relative working example that I readily use. For example, from the Query Azure CLI command output, there is a disregard for how the returned output is wrapped in the value
key —as explained via an issue in GitHub; but even when trying that syntax I don't get any positive results.
What I need to do is return the set that resembles the following:
az rest --method get --url https://graph.microsoft.com/v1.0/directoryRoles/ --query "[?contains(displayName,'Administrator')]" --output json
The expected return should be:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryRoles",
"value": [
{
"deletedDateTime": null,
"displayName": "Foo Administrator",
"id": "09fe6ef5-4af5-650d-a2e5-63895bba8f16",
"otherId": "4d2ac1ba-3253-41a0-a1f9-a3e0f568773a"
},
{
"deletedDateTime": null,
"displayName": "Bar Administrator",
"id": "1602300e-a17b-42d0-97a2-e3d0f0c1fa14",
"otherId": "fda7a751-a60a-444b-974d-02352ee8fa1c"
},
{
"deletedDateTime": null,
"displayName": "Foobar Service Administrator",
"id": "f94ad3a3-5e69-4638-b47d-e4df2d831dc8",
"otherId": "59091246-12e8-4a86-aa5a-066175b1a7a8"
},
[...]
Upvotes: 0
Views: 2166
Reputation: 41
... so per the Microsoft Graph documentation, the contains
string operator is not supported on any resources. But I was able to pipe out my array via jq
:
az rest --method get --url https://graph.microsoft.com/v1.0/directoryRoles/ \
| jq '.value[] | select(.displayName | contains("Administrator"))'
Upvotes: 1