如何通过Execute Pipeline活动将数组作为参数传递给子管道?
如何在Execute Pipeline活动中正确传递数组参数给子管道?
问题描述
在Data Factory项目中,需通过Execute Pipeline活动将数组参数传递给子管道,但尝试两种方法均失败:
- 直接在参数字段传入数组
["123456", "7891011"],系统将其解析为字符串; - 使用动态内容
array("123456", "7891011"),子管道的ForEach活动仍报错,提示参数为字符串而非数组。
错误信息
Operation on target ForEachBoard failed: The execution of template action 'MainForEachBoard' failed: The result of the evaluation of 'foreach' expression '@pipeline().parameters.boards' is of type 'String'. The result must be a valid array.
当前配置片段
{ "name": "Execute Updates", "type": "ExecutePipeline", "dependsOn": [ { "activity": "Execute Raw Data", "dependencyConditions": [ "Succeeded" ] } ], "policy": { "secureInput": false }, "userProperties": [], "typeProperties": { "pipeline": { "referenceName": "Updates_StageAndLoad", "type": "PipelineReference" }, "waitOnCompletion": true, "parameters": { "boards": { "value": "array(\"123456\", \"7891011\")", "type": "Expression" }, "stage_foldername": "updates" } } }
解决方案
1. 确认子管道参数类型
首先检查子管道中boards参数的类型,必须设置为Array而非String。如果参数类型是String,即使传入数组也会被强制转换为字符串格式,导致ForEach活动报错。
2. 修正Execute Pipeline活动的表达式配置
当前配置中,表达式的转义引号导致解析错误,需按以下方式修改boards参数:
"boards": { "value": "@array('123456', '7891011')", "type": "Expression" }
关键注意点:
- 动态表达式必须以
@开头,这是Data Factory识别动态内容的标识; - 使用单引号包裹数组元素,避免双引号的转义问题;
array()函数会直接返回数组类型,而非字符串。
3. 验证参数传递
运行父管道后,在子管道的监控页面查看boards参数的实际值,确认其类型为Array。同时检查子管道ForEach活动的Items表达式是否正确引用参数:@pipeline().parameters.boards。
扩展场景:引用其他活动输出的数组
如果数组值来自Lookup等活动的输出,可直接引用输出数组,无需额外转换:
"boards": { "value": "@activity('LookupBoards').output.value", "type": "Expression" }
内容的提问来源于stack exchange,提问作者Bilesh Ganguly
相关产品推荐
相关产品推荐

