Skip to content

Commit 9dcde6e

Browse files
authored
Merge pull request #227629 from n0elleli/pipelinedocupdate
Pipelinedocupdate
2 parents 878a792 + af82d5a commit 9dcde6e

File tree

2 files changed

+40
-13
lines changed

2 files changed

+40
-13
lines changed

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

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
title: Set Variable Activity
33
titleSuffix: Azure Data Factory & Azure Synapse
4-
description: Learn how to use the Set Variable activity to set the value of an existing variable defined in an Azure Data Factory or Azure Synapse Analytics pipeline.
4+
description: Learn how to use the Set Variable activity to set the value of an existing variable defined in an Azure Data Factory or Azure Synapse Analytics pipeline or to set a pipeline return value.
55
ms.service: data-factory
66
ms.subservice: orchestration
77
ms.custom: synapse
88
ms.topic: conceptual
9-
ms.date: 10/24/2022
9+
ms.date: 02/16/2023
1010
author: chez-charlie
1111
ms.author: chez
1212
ms.reviewer: jburchel
@@ -15,19 +15,43 @@ 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).
1919

20-
## Create an Append Variable activity with UI
20+
## Create a Set Variable activity with UI
2121

2222
To use a Set Variable activity in a pipeline, complete the following steps:
23+
2324
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+
:::image type="content" source="media/control-flow-activities-common/add-pipeline-array-variable.png" alt-text="Screenshot of an empty pipeline canvas with the Variables tab selected with an array type variable named TestVariable.":::
27+
28+
2. Search for _Set Variable_ in the pipeline Activities pane, and drag a Set Variable activity to the pipeline canvas.
29+
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.
31+
32+
4. Select the variable for the Name property.
33+
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).
35+
36+
:::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.":::
37+
38+
## Setting a pipeline return value in the Set Variable activity with UI
39+
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:
2543

2644
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).
30-
:::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.":::
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**.
49+
50+
4. Enter a **Name** for your variable and select the **Type** from the drop-down menu.
51+
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).
53+
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.":::
3155

3256
## Type properties
3357

@@ -36,13 +60,16 @@ Property | Description | Required
3660
name | Name of the activity in pipeline | yes
3761
description | Text describing what the activity does | no
3862
type | Must be set to **SetVariable** | yes
39-
value | String literal or expression object value that the variable is assigned to | yes
4063
variableName | Name of the variable that is set by this activity | yes
64+
value | String literal or expression object value that the variable is assigned to | yes
65+
4166

4267
## Incrementing a variable
4368

44-
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.
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.
70+
4571
Below is an example of this pattern:
72+
4673
:::image type="content" source="media/control-flow-set-variable-activity/increment-variable.png" alt-text="Screenshot shows increment variable.":::
4774

4875
``` json
@@ -99,10 +126,10 @@ Below is an example of this pattern:
99126
}
100127
```
101128

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.
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.
130+
103131

104132
## Next steps
105133
Learn about another related control flow activity:
106-
107134
- [Append Variable Activity](control-flow-append-variable-activity.md)
108135

131 KB
Loading

0 commit comments

Comments
 (0)