英文:
Custom query with more than one field on az ad sp list
问题
az ad sp list --query '[].{id:id, appId:appId}'
英文:
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}
]
答案1
得分: 1
当在JMESPath中执行多选(multiselect)操作时,您可以重新键入对象,因此需要指定一个新键和一个现有键。当然,新键可以与现有键相同。
因此,如果您不想更改键,您的查询应该是:
[].{id: id, appId: appId}
而您的Azure命令是:
az ad sp list --query '[].{id: id, appId: appId}'
英文:
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}'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论