I am currently working on a project where I have to call a few pipelines one after the other. For one such pipeline, I have to pass an array of values as a parameter through the Pipeline Execute activity. I have tried several approaches, but I am struggling to get the correct syntax and setup.
Here's what I've tried so far:
Directly passing the array in the parameter field of the Pipeline Execute activity, but it seems to interpret it as a string.
["123456", "7891011"]
Using dynamic content to create an array, but I'm not sure how to correctly pass this array to another pipeline.
array("123456", "7891011")
Following is the error that I get in both cases.
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.
Here's a snippet of what my current setup looks like:
{
"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"
}
}
}
Can someone help me figure out the correct way to pass an actual array as a parameter so that it can be used in the child pipeline? What changes should I make to the dynamic content or the overall setup?
You are passing string to the child pipeline parameter which is causing the above error when you gave that parameter to the For-Each.
To achieve your requirement, follow below steps.
First, create an array parameter in the child pipeline and don't give any value in the default value. You can use this array parameter as per your requirement with expression @pipeline().parameters.<parameter_name>
.
In the parent pipeline, take Execute pipeline activity and give your child pipeline. Give the expression @createarray(123456,7891011)
to the array parameter like below.
This expression creates an array of integers like [123456,7891011]
. If you want array of strings like ["123456", "7891011"]
, then use expression @createarray('123456','7891011')
.
For sample pipeline run, I have given my array parameter to an array variable in the child pipeline. I have executed the parent pipeline, and you can required array in the child pipeline run.