Skip to content

Commit 97a381c

Browse files
Merge pull request #227709 from chez-charlie/release-branch-1
Release branch 1
2 parents 4b40348 + e1c7a2b commit 97a381c

8 files changed

+106
-17
lines changed

articles/data-factory/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ items:
761761
- name: Set Variable activity
762762
href: control-flow-set-variable-activity.md
763763
displayName: variables, control flow
764+
- name: Set Pipeline Return Value
765+
href: tutorial-pipeline-return-value.md
764766
- name: Switch activity
765767
href: control-flow-switch-activity.md
766768
displayName: control flow

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,24 @@ To use a Set Variable activity in a pipeline, complete the following steps:
2727

2828
2. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
2929

30-
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.
30+
3. Select the Set Variable activity on the canvas if it isn't already selected, and then select 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 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 don't need to define the variable, 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

@@ -66,7 +59,7 @@ value | String literal or expression object value that the variable is assigned
6659

6760
## Incrementing a variable
6861

69-
A common scenario involving variables is to use a variable as an iterator within an **Until** or **ForEach** activity. In a **Set variable** activity, you can't reference the variable being set in the `value` field. To work around this limitation, set a temporary variable and then create a second **Set variable** activity. The second **Set variable** activity sets the value of the iterator to the temporary variable.
62+
A common scenario involving variable is to use a variable as an iterator within an **Until** or **ForEach** activity. In a **Set variable** activity, you can't reference the variable being set in the `value` field. To work around this limitation, set a temporary variable and then create a second **Set variable** activity. The second **Set variable** activity sets the value of the iterator to the temporary variable.
7063

7164
Below is an example of this pattern:
7265

@@ -126,7 +119,7 @@ Below is an example of this pattern:
126119
}
127120
```
128121

129-
Variables are currently scoped at the pipeline level. This means that they're not thread safe and can cause unexpected and undesired behavior if they are accessed from within a parallel iteration activity such as a ForEach loop, especially when the value is also being modified within that foreach activity.
122+
Variables are currently scoped at the pipeline level. This means that they're not thread safe and can cause unexpected and undesired behavior if they're accessed from within a parallel iteration activity such as a ForEach loop, especially when the value is also being modified within that foreach activity.
130123

131124

132125
## Next steps
34.9 KB
Loading
62.3 KB
Loading
92.2 KB
Loading
69.1 KB
Loading
36.2 KB
Loading
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 then be 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+
## Prerequisite - Calling a Child Pipeline
25+
26+
The prerequisite of the use case, is that you've an [Execute Pipeline Activity](control-flow-execute-pipeline-activity.md), calling a child pipeline. It's 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've expanded the [Set Variable activity](control-flow-set-variable-activity.md) to include system variables _Pipeline Return Value_. You don't 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 isn't already selected, and then its **Variables** tab, to edit its details.
37+
1. Choose _Pipeline return value_ for variable type.
38+
1. Select _New_ to add a new key value pair.
39+
1. You can add reasonable number 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 is 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__ complicated use cases only. It allows you to embed a list of key value pairs type for the value
55+
56+
Value of object type is 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 becomes 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. For instance, you may use
67+
* An _int_ value from child pipeline to define the wait period for a [wait activity](control-flow-wait-activity.md)
68+
* A _sting_ value to define the URL for the [Web activity](control-flow-web-activity.md)
69+
* An _expression_ value payload for a [script activity](transform-data-using-script.md) for logging purposes.
70+
71+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-03-calling-pipeline.png" alt-text="Screenshot shows the calling pipeline.":::
72+
73+
There are two noticeable call outs in referencing the pipeline return values.
74+
75+
1. With _Object_ type, you may further expand into the nested json object, such as _@activity('Execute Pipeline1').output.pipelineReturnValue.keyName.nextLevelKey_
76+
2. 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.
77+
78+
> [!NOTE]
79+
> 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.
80+
> Pipeline will fail if the key referenced is missing in the payload
81+
82+
## Special Considerations
83+
84+
You may have multiple Set Pipeline Return value activities in a pipeline. However, please ensure that only one gets to run in a pipeline.
85+
86+
:::image type="content" source="media/pipeline-return-value/pipeline-return-value-04-multiple.png" alt-text="Screenshot with Pipeline Return Value and Branching.":::
87+
88+
To avoid missing key situation in the calling pipeline, described above, we encourage you to have the same list of keys for all branches in child pipeline. Consider using _null_ types for keys that don't have values, in a specific branch.
89+
90+
## Next steps
91+
Learn about another related control flow activity:
92+
- [Set Variable Activity](control-flow-set-variable-activity.md)
93+
- [Append Variable Activity](control-flow-append-variable-activity.md)
94+

0 commit comments

Comments
 (0)