Why dynamic pipelines?
Without parameters, ShopKart would need one pipeline per table, per file and per date. With them, one pipeline takes tableName and runDate and builds every path, query and file name itself. Every expression in this lesson was evaluated for real, so you can see exactly what each one returns.
The four kinds of values
| Kind | How you read it | Can change during a run? | Set by |
|---|---|---|---|
| Pipeline parameter | @pipeline().parameters.runDate | No | Trigger, parent pipeline, manual run |
| Global parameter | @pipeline().globalParameters.env | No | Factory settings (per environment) |
| Variable | @variables('flagFound') | Yes: Set Variable / Append Variable | The pipeline itself |
| System variable | @pipeline().RunId, @pipeline().TriggerTime, @pipeline().Pipeline | No | ADF |
Parameter types: String, Int, Float, Bool, Array, Object, SecureString. Variable types: String, Boolean, Integer, Array.
A pipeline that shows every expression
PL_Expressions_Demo has typed parameters and one Set Variable activity per expression, chained so they run in order:
{
"name": "PL_Expressions_Demo",
"properties": {
"description": "One Set Variable per expression, to see exactly what each one returns.",
"parameters": {
"runDate": {
"type": "string",
"defaultValue": "2026-11-22"
},
"tableName": {
"type": "string",
"defaultValue": "orders"
},
"fileName": {
"type": "string",
"defaultValue": "orders_2026-11-22.csv"
},
"fullReload": {
"type": "bool",
"defaultValue": false
},
"cities": {
"type": "array",
"defaultValue": [
"Kolkata",
"Mumbai",
"Delhi",
"Bengaluru",
"Pune"
]
},
"config": {
"type": "object",
"defaultValue": {
"batchSize": "1000"
}
}
},
"variables": {
"folderPath": {
"type": "String"
},
"message": {
"type": "String"
},
"yesterday": {
"type": "String"
},
"isWeekend": {
"type": "String"
},
"loadType": {
"type": "String"
},
"cityCount": {
"type": "String"
},
"firstCity": {
"type": "String"
},
"hasPune": {
"type": "String"
},
"batchSize": {
"type": "String"
},
"owner": {
"type": "String"
},
"extension": {
"type": "String"
},
"upperTable": {
"type": "String"
},
"runInfo": {
"type": "String"
},
"seenCities": {
"type": "Array"
}
},
"activities": [
{
"name": "Folder Path",
"type": "SetVariable",
"typeProperties": {
"variableName": "folderPath",
"value": {
"value": "@concat('raw/orders/', formatDateTime(pipeline().parameters.runDate, 'yyyy/MM/dd'))",
"type": "Expression"
}
}
},
{
"name": "Interpolated Message",
"type": "SetVariable",
"typeProperties": {
"variableName": "message",
"value": {
"value": "Loading @{pipeline().parameters.tableName} for @{pipeline().parameters.runDate} in @{pipeline().globalParameters.env}",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Folder Path",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Yesterday",
"type": "SetVariable",
"typeProperties": {
"variableName": "yesterday",
"value": {
"value": "@formatDateTime(addDays(pipeline().parameters.runDate, -1), 'yyyy-MM-dd')",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Interpolated Message",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Is Weekend",
"type": "SetVariable",
"typeProperties": {
"variableName": "isWeekend",
"value": {
"value": "@string(or(equals(dayOfWeek(pipeline().parameters.runDate), 0), equals(dayOfWeek(pipeline().parameters.runDate), 6)))",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Yesterday",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Load Type",
"type": "SetVariable",
"typeProperties": {
"variableName": "loadType",
"value": {
"value": "@if(pipeline().parameters.fullReload, 'FULL', 'INCREMENTAL')",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Is Weekend",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "City Count",
"type": "SetVariable",
"typeProperties": {
"variableName": "cityCount",
"value": {
"value": "@string(length(pipeline().parameters.cities))",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Load Type",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "First City",
"type": "SetVariable",
"typeProperties": {
"variableName": "firstCity",
"value": {
"value": "@first(pipeline().parameters.cities)",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "City Count",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Has Pune",
"type": "SetVariable",
"typeProperties": {
"variableName": "hasPune",
"value": {
"value": "@string(contains(pipeline().parameters.cities, 'Pune'))",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "First City",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Batch Size",
"type": "SetVariable",
"typeProperties": {
"variableName": "batchSize",
"value": {
"value": "@string(add(int(pipeline().parameters.config.batchSize), 500))",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Has Pune",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Owner Or Default",
"type": "SetVariable",
"typeProperties": {
"variableName": "owner",
"value": {
"value": "@coalesce(pipeline().parameters.config?.owner, 'data-team')",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Batch Size",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "File Extension",
"type": "SetVariable",
"typeProperties": {
"variableName": "extension",
"value": {
"value": "@last(split(pipeline().parameters.fileName, '.'))",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Owner Or Default",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Upper Table",
"type": "SetVariable",
"typeProperties": {
"variableName": "upperTable",
"value": {
"value": "@toUpper(pipeline().parameters.tableName)",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "File Extension",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Run Info",
"type": "SetVariable",
"typeProperties": {
"variableName": "runInfo",
"value": {
"value": "@concat(pipeline().Pipeline, ' / run ', pipeline().RunId)",
"type": "Expression"
}
},
"dependsOn": [
{
"activity": "Upper Table",
"dependencyConditions": [
"Succeeded"
]
}
]
},
{
"name": "Remember City",
"type": "AppendVariable",
"dependsOn": [
{
"activity": "Run Info",
"dependencyConditions": [
"Succeeded"
]
}
],
"typeProperties": {
"variableName": "seenCities",
"value": {
"value": "@pipeline().parameters.cities[1]",
"type": "Expression"
}
}
}
]
}
}We evaluated it with Microsoft's testing framework, supplying the global parameter and system variables a real run would have:
from data_factory_testing_framework import TestFramework, TestFrameworkType
from data_factory_testing_framework.state import RunParameter, RunParameterType
tf = TestFramework(framework_type=TestFrameworkType.DataFactory, root_folder_path="shopkart-adf")
pipeline = tf.get_pipeline_by_name("PL_Expressions_Demo")
run = tf.evaluate_pipeline(pipeline, [
RunParameter(RunParameterType.Global, "env", "dev"),
RunParameter(RunParameterType.System, "Pipeline", "PL_Expressions_Demo"),
RunParameter(RunParameterType.System, "RunId", "7c1d2e9a"),
])
for activity in run:
print(f"{activity.name:<22} → {activity.type_properties['value'].result!r}")Folder Path → 'raw/orders/2026/11/22'
Interpolated Message → 'Loading orders for 2026-11-22 in dev'
Yesterday → '2026-11-21'
Is Weekend → 'True'
Load Type → 'INCREMENTAL'
City Count → '5'
First City → 'Kolkata'
Has Pune → 'True'
Batch Size → '1500'
Owner Or Default → 'data-team'
File Extension → 'csv'
Upper Table → 'ORDERS'
Run Info → 'PL_Expressions_Demo / run 7c1d2e9a'
Remember City → 'Mumbai'What each one teaches
| Expression | Result | Lesson |
|---|---|---|
| concat('raw/orders/', formatDateTime(runDate, 'yyyy/MM/dd')) | raw/orders/2026/11/22 | Build lake paths from dates |
| Loading @{tableName} for @{runDate} in @{env} | Loading orders for 2026-11-22 in dev | @{ } interpolation inside text |
| formatDateTime(addDays(runDate, -1), 'yyyy-MM-dd') | 2026-11-21 | Date math: addDays, addHours, startOfMonth... |
| or(equals(dayOfWeek(runDate), 0), equals(dayOfWeek(runDate), 6)) | True | Logic: and, or, not, equals, greater; 0 = Sunday |
| if(fullReload, 'FULL', 'INCREMENTAL') | INCREMENTAL | if(condition, then, else) |
| length(cities), first(cities), contains(cities, 'Pune') | 5, Kolkata, True | Arrays |
| add(int(config.batchSize), 500) | 1500 | Type conversion: int, string, float, bool, json |
| coalesce(config?.owner, 'data-team') | data-team | ?. for missing properties + a default |
| last(split(fileName, '.')) | csv | Text: split, substring, replace, toUpper, trim, endswith |
| concat(pipeline().Pipeline, ' / run ', pipeline().RunId) | PL_Expressions_Demo / run 7c1d2e9a | System variables for logging |
| cities[1] (Append Variable) | Mumbai | Array index starts at 0 |
Expression rules to remember
| Rule | Example |
|---|---|
| A value starting with @ is an expression | @pipeline().parameters.runDate |
| @{ } inside text interpolates (result is text) | file_@{formatDateTime(utcNow(), 'yyyyMMdd')}.csv |
| Strings use single quotes; double them to escape | 'It''s done' |
| Start with @@ for a literal text that begins with @ | @@handle → text @handle |
| Activity outputs | @activity('Get New Watermark').output.firstRow.new_watermark |
| Inside ForEach, the current element | @item().name |
| Dataset parameters inside a dataset | @dataset().fileName |
| utcNow() for 'now'; convertFromUtc() for India time | convertFromUtc(utcNow(), 'India Standard Time') |
Function names are case-insensitive, but keep them as documented (formatDateTime, utcNow) for readability. Date format strings follow .NET: yyyy year, MM month, dd day, HH 24-hour, mm minutes. Mixing up MM and mm is a classic bug.
Variables in parallel loops: a trap
Pipeline variables are shared by the whole run. Inside a parallel ForEach, several iterations can write the same variable at once and overwrite each other. Use a sequential ForEach, pass values as parameters to a child pipeline (each run has its own variables), or use Append Variable only where order doesn't matter.
🎯 Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1Difference between parameters and variables in ADF?Fresher+
Q2How do you make a file name include today's date?Fresher+
Q3What are global parameters and why use them?1–3 yrs+
Q4How do you read the output of a previous activity?1–3 yrs+
Q5Why is using utcNow() inside a daily load risky, and what do you do instead?3+ yrs+
Key takeaways
- ✓Parameters in, variables during, expressions everywhere.
- ✓Every expression here was evaluated, so trust the results table.
- ✓Use ?., coalesce and a runDate parameter to avoid the classic failures.
- ✓Watch shared variables in parallel loops.
Frequently asked questions
What is dynamic content in ADF?
Any property value written as an expression instead of fixed text. In Studio you click 'Add dynamic content' and write something like @concat('raw/', pipeline().parameters.tableName). ADF evaluates it at run time.
Parameter or variable?
Parameters are inputs: set when the run starts (by a trigger, a parent pipeline or you) and read-only during the run. Variables are working values you change during the run with Set Variable or Append Variable.
What's the difference between @ and @{ }?
A value starting with @ is a whole expression and can return any type (string, number, array, object). @{ } inside normal text is string interpolation: the result is always text, like 'Loading @{pipeline().parameters.tableName}'.
How do I write a single quote inside an expression string?
Double it: 'It''s done' is the text It's done. We used '''' (a string containing one quote) in the alert pipeline to replace double quotes in error messages.
Why does my expression fail with 'property doesn't exist'?
You read a property that isn't there, like config.owner when config has no owner. Use the ?. operator (config?.owner) to get null instead of an error, and coalesce() to supply a default.
🧠 Quick check: parameters and expressions
1. Which returns text no matter what?
2. formatDateTime(addDays('2026-11-22', -1), 'yyyy-MM-dd') returns...
3. pipeline().parameters.config.owner fails because owner doesn't exist. Fix?
4. Which can change during a run?
5. dayOfWeek() returns 0 for...
Checking your access…