Search code examples
azureazure-pipelinespipelineazure-data-factory

How to pass variable from a child pipeline to master pipeline?


I have a child pipeline on Azure Data Factory which is called by a master one by an "Execute Pipeline" activity. This child pipeline has a couple of variables which I need in my master pipeline.

On this child pipeline I even use some "Set variable" activities to change the variables values. Like in the example:

Child Pipeline

I would like to pass this final values of my variables from child pipeline to the master one. If every step run successfully, my variables would have all "true" values at the end of my child pipeline. I would like this values to be passed to the master pipeline. Like in the example:

Master Pipeline

Is it possible?


Solution

  • It is not possible to pass/return variables from child pipelines to parent pipelines. We can only pass parameters from parent pipeline to child pipeline.

    A work around to this problem is to write the values into a file (txt) in the child pipeline and read this file from parent pipeline. Look at the following demonstration.

    • Let's say you have a text file (with some data) in the storage account. In child pipeline, after the copy and set variable activity completion, create a copy data activity.

    enter image description here

    • The source dataset would be the above text file without first row as header. Here add additional columns, with your variable values.

    enter image description here

    • Select sink (without header). In mappings, import schema and delete the columns that are not required.

    enter image description here

    • Invoke this pipeline from parent pipeline, the values will be written as a text file (as shown in the below image)

    enter image description here

    • You can finally read this file in parent pipeline (using lookup) and utilize those values.