You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
19
19
20
-
## Create an Append Variable activity with UI
20
+
21
+
## Setting a variable in the Set Variable activity with UI
21
22
22
23
To use a Set Variable activity in a pipeline, complete the following steps:
24
+
23
25
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.":::
25
26
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).
30
33
:::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.":::
description | Text describing what the activity does | no
38
41
type | Must be set to **SetVariable** | yes
39
-
value | String literal or expression object value that the variable is assigned to | yes
40
42
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
+
41
59
42
60
## Incrementing a variable
43
61
44
62
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.
@@ -99,7 +118,8 @@ Below is an example of this pattern:
99
118
}
100
119
```
101
120
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
+
103
123
104
124
## Next steps
105
125
Learn about another related control flow activity:
0 commit comments