Skip to content

Commit 5c9fa71

Browse files
authored
Merge pull request #110554 from djpmsft/docUpdates
Add set variable example
2 parents 23b1ab3 + 78c3014 commit 5c9fa71

File tree

2 files changed

+67
-6
lines changed

2 files changed

+67
-6
lines changed

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

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,89 @@ services: data-factory
55
documentationcenter: ''
66
ms.service: data-factory
77
ms.workload: data-services
8-
98
ms.topic: conceptual
10-
ms.date: 10/10/2018
9+
ms.date: 04/07/2020
1110
author: djpmsft
1211
ms.author: daperlov
1312
manager: jroth
1413
ms.reviewer: maghan
1514
---
16-
# Set Variable Activity in Azure Data Factory
15+
# Set variable activity in Azure Data Factory
1716

1817
Use the Set Variable activity to set the value of an existing variable of type String, Bool, or Array defined in a Data Factory pipeline.
1918

2019
## Type properties
2120

2221
Property | Description | Required
2322
-------- | ----------- | --------
24-
name | Name of the activity in pipeline | Yes
23+
name | Name of the activity in pipeline | yes
2524
description | Text describing what the activity does | no
26-
type | Activity Type is SetVariable | yes
27-
value | String literal or expression object value used to set specified variable | yes
25+
type | Must be set to **SetVariable** | yes
26+
value | String literal or expression object value that the variable will be assigned to | yes
2827
variableName | Name of the variable that will be set by this activity | yes
2928

29+
## Incrementing a variable
30+
31+
A common scenario involving variables in Azure Data Factory 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 workaround 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.
32+
33+
Below is an example of this pattern:
34+
35+
![Increment variable](media/control-flow-set-variable-activity/increment-variable.png "Increment variable")
36+
37+
``` json
38+
{
39+
"name": "pipeline3",
40+
"properties": {
41+
"activities": [
42+
{
43+
"name": "Set I",
44+
"type": "SetVariable",
45+
"dependsOn": [
46+
{
47+
"activity": "Increment J",
48+
"dependencyConditions": [
49+
"Succeeded"
50+
]
51+
}
52+
],
53+
"userProperties": [],
54+
"typeProperties": {
55+
"variableName": "i",
56+
"value": {
57+
"value": "@variables('j')",
58+
"type": "Expression"
59+
}
60+
}
61+
},
62+
{
63+
"name": "Increment J",
64+
"type": "SetVariable",
65+
"dependsOn": [],
66+
"userProperties": [],
67+
"typeProperties": {
68+
"variableName": "j",
69+
"value": {
70+
"value": "@string(add(int(variables('i')), 1))",
71+
"type": "Expression"
72+
}
73+
}
74+
}
75+
],
76+
"variables": {
77+
"i": {
78+
"type": "String",
79+
"defaultValue": "0"
80+
},
81+
"j": {
82+
"type": "String",
83+
"defaultValue": "0"
84+
}
85+
},
86+
"annotations": []
87+
}
88+
}
89+
```
90+
3091

3192
## Next steps
3293
Learn about a related control flow activity supported by Data Factory:
16.3 KB
Loading

0 commit comments

Comments
 (0)