Lets say I want to list id and appId from az ad sp list, how would one do that?
I get it working for only the id like this:
az ad sp list --query '[].id'
How can I extend this to id and appId?
I already tried
az ad sp list --query '[].id,[].appId'
az ad sp list --query '[].{id,appId}'
but both are invalid queries.
The output I am looking for should be something like
[
{"id": 1, "appId": 2},
{"id": 3, "appId": 4}
]
>Solution :
When doing a multiselect in JMESPath, you can re-key your objects, so you will need to specify both a new key and an existing key. Of course, the new key can be the same as the existing one.
So, if you don’t want to change the keys, your query should be:
[].{id: id, appId: appId}
And your Azure command:
az ad sp list --query '[].{id: id, appId: appId}'