Skip to content

Commit baa1834

Browse files
committed
Pipeline Return Value
1 parent 03c395f commit baa1834

7 files changed

+100
-14
lines changed

articles/data-factory/control-flow-set-variable-activity.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,22 @@ To use a Set Variable activity in a pipeline, complete the following steps:
2929

3030
3. Select the Set Variable activity on the canvas if it isn't already selected, and then click the **Settings** tab to edit its details.
3131

32-
4. Select the variable for the Name property.
32+
4. Select **Pipeline variable** for your **Variable type**.
3333

34-
5. Enter an expression to set the value for the variables. This expression can be a literal string expression, or any combination of dynamic [expressions, functions](control-flow-expression-language-functions.md), [system variables](control-flow-system-variables.md), or [outputs from other activities](how-to-expression-language-functions.md#examples-of-using-parameters-in-expressions).
34+
5. Select the variable for the Name property.
35+
36+
6. Enter an expression to set the value for the variables. This expression can be a literal string expression, or any combination of dynamic [expressions, functions](control-flow-expression-language-functions.md), [system variables](control-flow-system-variables.md), or [outputs from other activities](how-to-expression-language-functions.md#examples-of-using-parameters-in-expressions).
3537

3638
:::image type="content" source="media/control-flow-set-variable-activity/set-variable-activity.png" alt-text="Screenshot of the UI for a Set variable activity.":::
3739

3840
## Setting a pipeline return value in the Set Variable activity with UI
3941

40-
The Set Variable activity now allows you to set a pipeline return value (preview). The pipeline return value is a system variable that allows you to customize a value that can be consumed by a parent pipeline and used downstream in your pipeline.
41-
42-
To set a pipeline return value, complete the following steps:
43-
44-
1. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
45-
46-
2. Select the Set Variable activity on the canvas if it isn't already selected, and then click the **Settings** tab to edit its details.
47-
48-
3. Select **Pipeline return value (preview)** for your **Variable type**.
42+
We have expanded Set Variable activity to include a special system variable, named _Pipeline Return Value_. This allows communication from the child pipeline to the calling pipeline, in the following scenario.
4943

50-
4. Enter a **Name** for your variable and select the **Type** from the drop-down menu.
44+
You do not need to define the varible, before using it. For more information, see [Pipeline Return Value](tutorial-pipeline-return-value.md)
5145

52-
5. Enter an expression to set the value for the pipeline return value. This expression can be a literal string expression, or any combination of dynamic [expressions, functions](control-flow-expression-language-functions.md), [system variables](control-flow-system-variables.md), or [outputs from other activities](how-to-expression-language-functions.md#examples-of-using-parameters-in-expressions).
5346

54-
:::image type="content" source="media/control-flow-set-variable-activity/set-pipeline-return-value.png" alt-text="Screenshot of the UI for setting a pipeline return value.":::
47+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-00-paradigm.png" alt-text="Screenshot with ExecutePipeline Activity.":::
5548

5649
## Type properties
5750

34.9 KB
Loading
62.3 KB
Loading
92.2 KB
Loading
69.1 KB
Loading
36.2 KB
Loading
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Set Pipeline Return Value
3+
titleSuffix: Azure Data Factory & Azure Synapse
4+
description: Learn how to use the Set Variable activity to send information from child pipeline to main pipeline
5+
ms.service: data-factory
6+
ms.subservice: orchestration
7+
ms.custom: synapse
8+
ms.topic: conceptual
9+
ms.date: 2/12/2022
10+
author: chez-charlie
11+
ms.author: chez
12+
ms.reviewer: jburchel
13+
---
14+
15+
# Set Pipeline Return Value in Azure Data Factory and Azure Synapse Analytics
16+
[!INCLUDE[appliesto-adf-asa-md](includes/appliesto-adf-asa-md.md)]
17+
18+
In the calling pipeline-child pipeline paradigm, you can use the [Set Variable activity](control-flow-set-variable-activity.md) to return values from the child pipeline to the calling pipeline. In the following scenario, we have a child pipeline through [Execute Pipeline Activity](control-flow-execute-pipeline-activity.md). And we want to __retrieve information from the child pipeline__, to be sebsequently used in the calling pipeline.
19+
20+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-00-paradigm.png" alt-text="Screenshot with ExecutePipeline Activity.":::
21+
22+
Introduce pipeline return value, a dictionary of key value pairs, that allows communications between child pipelines and parent pipeline.
23+
24+
## Pre-requesite - Calling a Child Pipeline
25+
26+
The pre-requesite of the use case, is that you have an [Execute Pipeline Activity](control-flow-execute-pipeline-activity.md), calling a child pipeline. It is important that we enabled _Wait on Completion_ for the activity
27+
28+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-01-execute-pipeline-setting.png" alt-text="Screenshot setting ExecutePipeline Activity to wait for completion.":::
29+
30+
31+
## Configure Pipeline Return Value in Child Pipeline
32+
33+
We have expanded the [Set Variable activity](control-flow-set-variable-activity.md) to include system variables _Pipeline Return Value_. You do not need to define them at pipeline level (as opposed to any other variables you use in the pipeline).
34+
35+
1. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
36+
1. Select the Set Variable activity on the canvas if it is not already selected, and then its **Variables** tab, to edit its details.
37+
1. Choose _Pipeline return value_ for variable type.
38+
1. Click _New_ to add a new key value pair.
39+
1. You can add resonable ammount of key value pairs, bounded by size limit of returning json.
40+
41+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-02-child-pipeline.png" alt-text="Screenshot shows the ui for pipeline return value.":::
42+
43+
There are a few options for value types, including
44+
45+
Type Name | Description
46+
-------- | -----------
47+
String | The most straight forward of all. It expects a string value.
48+
Expression | It allows you to reference output from previous activities.
49+
Array | It expects an array of _string values_. Press "enter" key to separate values in the array
50+
Boolean | True or False
51+
Null | Signal place holder status; the value will be constant _null_
52+
Int | It expects a numerical value of integer type
53+
Float | It expects a numerical value of float type
54+
Object | __Warning__ very complicated use cases only. It allows you to embed a list of key value pairs type, i.e. json, for the value
55+
56+
Object Type are defined as follows:
57+
58+
``` json
59+
[{"key": "myKey1", "value": {"type": "String", "content": "hello world"}},
60+
{"key": "myKey2", "value": {"type": "String", "content": "hi"}}
61+
]
62+
```
63+
64+
## Retrieving Value in Calling Pipeline
65+
66+
The pipeline return value of the child pipeline will become the activity output of the Execute Pipeline Activity. You can retrieve the information with _@activity('Execute Pipeline1').output.pipelineReturnValue.keyName_. The use case is limitless.
67+
68+
For instance, you may use an _int_ value from child pipeline to define the wait period for a [wait activity](control-flow-wait-activity.md), or a _sting_ value to definet the URL for the [Web activity](control-flow-web-activity.md), or _expression_ payload to a [script activity](transform-data-using-script.md) for logging purposes.
69+
70+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-03-calling-pipeline.png" alt-text="Screenshot shows the ui for pipeline return value.":::
71+
72+
There are 2 noticeable call outs in referencing the pipeline return values.
73+
74+
1. With _Object_ type, you may further expand into the nested json object, such as _@activity('Execute Pipeline1').output.pipelineReturnValue.keyName.nextLevelKey_
75+
1. With _Array_ type, you can specify the index in the list, with _@activity('Execute Pipeline1').output.pipelineReturnValue.keyName[0]_. The number is zero indexed, meaning that it starts with 0.
76+
77+
> [!NOTE]
78+
> Please make sure that the _keyName_ you are referencing exists in your child pipeline. ADF expression builder can _not_ confirm the referential check for you.
79+
> Pipeline will fail if the key referenced is missing in the payload
80+
81+
## Special Considerations
82+
83+
You may have multiple Set Pipeline Return value activities in a pipeline. However, please ensure that only one gets to run in a pipeline.
84+
85+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-04-multiple.png" alt-text="Screenshot with Pipeline Return Value and Branching.":::
86+
87+
To avoid missing key nissing situation in the calling pipeline, described above, we encourage you to have the same list of keys for all branches in child pipeline. Please consider using _null_ types for keys that doesn't have values, in a specific branch.
88+
89+
## Next steps
90+
Learn about another related control flow activity:
91+
- [Set Variable Activity](control-flow-set-variable-activity.md)
92+
- [Append Variable Activity](control-flow-append-variable-activity.md)
93+

0 commit comments

Comments
 (0)