You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

KQL如何将字典数组转为字符串数组?Azure Resource Graph查询求助

解决方案

你可以通过KQL提供的array_map函数直接处理动态数组,一行代码就能实现提取指定字段生成新数组的需求,查询写法如下:

Customers
| where customerId == 201
| project customerId, orders = array_map(d => d.dept, orders)

说明

  • array_map 是KQL提供的数组遍历处理函数,第一个参数为lambda表达式,第二个参数为待处理的数组
  • 示例中lambda表达式d => d.dept表示遍历orders数组的每一个元素d,提取其dept属性值
  • 函数最终返回的就是所有dept值组成的字符串数组,无需额外的展开、聚合操作,性能更高写法更简洁

如果你的运行环境不支持array_map函数,也可以使用mv-apply展开后再聚合的方式实现,写法如下:

Customers
| where customerId == 201
| project customerId, orders
| mv-apply orders on (
    project dept = orders.dept
    | summarize orders = make_list(dept)
)

内容的提问来源于stack exchange,提问作者Teo Nicholas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 02:06:01