Skip to content

Commit 0ce72ef

Browse files
authored
Update control-flow-set-variable-activity.md
adding section for setting pipeline return value
1 parent 21f7a26 commit 0ce72ef

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ ms.reviewer: jburchel
1515
# Set Variable Activity in Azure Data Factory and Azure Synapse Analytics
1616
[!INCLUDE[appliesto-adf-asa-md](includes/appliesto-adf-asa-md.md)]
1717

18-
Use the Set Variable activity to set the value of an existing variable of type String, Bool, or Array defined in a Data Factory or Synapse pipeline.
18+
Use the Set Variable activity to set the value of an existing variable of type String, Bool, or Array defined in a Data Factory or Synapse pipeline or use the Set Variable activity to set a pipeline return value (preview), which can be used in a parent pipeline.
1919

20-
## Create an Append Variable activity with UI
20+
21+
## Setting a variable in the Set Variable activity with UI
2122

2223
To use a Set Variable activity in a pipeline, complete the following steps:
24+
2325
1. Select the background of the pipeline canvas and use the Variables tab to add a variable:
24-
:::image type="content" source="media/control-flow-activities-common/add-pipeline-array-variable.png" alt-text="Screenshot shows an empty pipeline canvas with the variables tab selected having an array type variable named TestVariable.":::
2526

26-
1. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
27-
1. Select the Set Variable activity on the canvas if it is not already selected, and its **Variables** tab, to edit its details.
28-
1. Select the variable for the Name property.
29-
1. 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).
27+
:::image type="content" source="media/control-flow-activities-common/add-pipeline-array-variable.png" alt-text="Screenshot shows an empty pipeline canvas with the variables tab selected having an array type variable named TestVariable.":::
28+
29+
2. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
30+
3. Select the Set Variable activity on the canvas if it is not already selected, and then click the **Settings** tab to edit its details.
31+
4. Select the variable for the Name property.
32+
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).
3033
:::image type="content" source="media/control-flow-set-variable-activity/set-variable-activity.png" alt-text="Screenshot shows the ui for a set variable activity.":::
3134

3235
## Type properties
@@ -36,13 +39,29 @@ Property | Description | Required
3639
name | Name of the activity in pipeline | yes
3740
description | Text describing what the activity does | no
3841
type | Must be set to **SetVariable** | yes
39-
value | String literal or expression object value that the variable is assigned to | yes
4042
variableName | Name of the variable that is set by this activity | yes
43+
value | String literal or expression object value that the variable is assigned to | yes
44+
45+
## Setting a pipeline return value in the Set Variable activity with UI
46+
47+
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.
48+
49+
To set a pipeline return value, complete the following steps:
50+
51+
1. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
52+
2. Select the Set Variable activity on the canvas if it is not already selected, and then click the **Settings** tab to edit its details.
53+
4. Select **Pipeline return value (preview)** for your **Variable type**.
54+
5. Enter a **Name** for your variable and select the **Type** from the drop-down menu.
55+
6. 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).
56+
57+
:::image type="content" source="media/control-flow-set-variable-activity/set-pipeline-return-value.png" alt-text="Screenshot shows the UI for setting a pipeline return value.":::
58+
4159

4260
## Incrementing a variable
4361

4462
A common scenario involving variables is using a variable as an iterator within an until or foreach activity. In a set variable activity, you cannot 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.
4563
Below is an example of this pattern:
64+
4665
:::image type="content" source="media/control-flow-set-variable-activity/increment-variable.png" alt-text="Screenshot shows increment variable.":::
4766

4867
``` json
@@ -99,7 +118,8 @@ Below is an example of this pattern:
99118
}
100119
```
101120

102-
Variables are currently scoped at the pipeline level. This means that they are 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.
121+
Variables are currently scoped at the pipeline level. This means that they are 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+
103123

104124
## Next steps
105125
Learn about another related control flow activity:

0 commit comments

Comments
 (0)