自定义查询在Azure AD服务主体列表上使用多个字段。

huangapple go评论69阅读模式
英文:

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}'

huangapple
  • 本文由 发表于 2023年2月14日 03:00:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440169.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定