cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use variable values in Parent Workflow in Child Workflow.

eric2
New Contributor II

In ADF, a variable called Datetime was specified to be entered and executed in a workflow called Parent using Web Activity.

There is a Child Workflow (two-step workflow) in Parent Workflow, and Datetime variables are available in Parent Workflow, but Datetime variables are not available in Child Workflow.

In my opinion, I expected the variable to be inherited from Parent to Child, but it was not. How can I apply it to Child Workflow the same as Parent?

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @eric2In Azure Data Factory (ADF), you must use pipeline parameters to pass variables from a parent pipeline to a child pipeline. You can define parameters in your child pipeline and then pass the variable values when you execute the child pipeline from the parent pipeline.

Here are the steps to do it:

1. Define parameters in your child pipeline:
   - In your child pipeline, go to the ’Parameters’ tab and add a parameter. For example, you can name this parameter Datetime.

2. Pass the variable values from the parent pipeline:
   - In your parent pipeline, when you add the ’Execute Pipeline’ activity to call the child pipeline, you can pass the variable's value to the child pipeline. In the ’Parameters’ tab of the ’Execute Pipeline’ activity, add the same parameter Datetime and set its value to the variable Datetime from the parent pipeline. Note: The parameters in the parent and child pipelines should have the same name to pass the values correctly.

Here is a sample code to pass the variable:

json
{
   "name": "Execute Child Pipeline",
   "type": "ExecutePipeline",
   "parameters": {
       "Datetime": "@variables('Datetime')"
   },
   "linkedServiceName": {
       "referenceName": "ChildPipeline",
       "type": "LinkedServiceReference"
   }
}

In this code, @variables('Datetime') is used to get the value of the Datetime Variable from the parent pipeline and pass it to the child pipeline. 

View solution in original post

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @eric2In Azure Data Factory (ADF), you must use pipeline parameters to pass variables from a parent pipeline to a child pipeline. You can define parameters in your child pipeline and then pass the variable values when you execute the child pipeline from the parent pipeline.

Here are the steps to do it:

1. Define parameters in your child pipeline:
   - In your child pipeline, go to the ’Parameters’ tab and add a parameter. For example, you can name this parameter Datetime.

2. Pass the variable values from the parent pipeline:
   - In your parent pipeline, when you add the ’Execute Pipeline’ activity to call the child pipeline, you can pass the variable's value to the child pipeline. In the ’Parameters’ tab of the ’Execute Pipeline’ activity, add the same parameter Datetime and set its value to the variable Datetime from the parent pipeline. Note: The parameters in the parent and child pipelines should have the same name to pass the values correctly.

Here is a sample code to pass the variable:

json
{
   "name": "Execute Child Pipeline",
   "type": "ExecutePipeline",
   "parameters": {
       "Datetime": "@variables('Datetime')"
   },
   "linkedServiceName": {
       "referenceName": "ChildPipeline",
       "type": "LinkedServiceReference"
   }
}

In this code, @variables('Datetime') is used to get the value of the Datetime Variable from the parent pipeline and pass it to the child pipeline. 

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!