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

如何在Logic Apps中提取Azure Function返回的数组值到变量?

解决Azure Function返回数组在Logic Apps中无法识别的问题

方案一:修改Azure Function代码(推荐)

你当前的代码用JSON.stringify()把数组转成了字符串,导致Logic Apps接收到的是字符串而非JSON数组。直接返回数组即可,Azure Functions会自动完成JSON序列化:

context.res = {
    status: 200,
    body: [myString, date, reqId],
    headers: {
        'Content-Type': 'application/json'
    }
};

修改后,Logic Apps会直接识别返回结果为数组,你可以通过索引[0]、[1]、[2]直接提取三个元素到变量中。

方案二:在Logic Apps中处理现有返回结果

如果无法修改Azure Function代码,可通过以下步骤在Logic Apps中解析字符串为数组:

  • 添加「Parse JSON」动作,将Azure Function的输出内容作为输入,使用如下JSON Schema:
{
    "type": "array",
    "items": {
        "type": "string"
    }
}
  • 解析完成后,通过索引提取元素:
    • 第一个值:body('Parse_JSON')[0]
    • 第二个值:body('Parse_JSON')[1]
    • 第三个值:body('Parse_JSON')[2]
  • 将上述表达式的结果分别赋值给对应的变量即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 00:29:58