(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to use the If Condition activity in Azure Data Factory

João Barros 16 de July de 2026 4 min read

The If Condition activity in Azure Data Factory lets you branch a pipeline based on a condition that returns true or false, just like an if statement in a programming language. It is the simplest way to make sure certain activities only run when a rule is met — for example, copying data only when there are new files in a folder. It is an essential control-flow activity, and you configure all of it in the Azure Data Factory Studio, without writing code.

Prerequisites

  • An Azure Data Factory instance already created, with access to the Azure Data Factory Studio.
  • A pipeline, new or existing, where you can add activities.
  • Basic knowledge of the pipeline canvas: dragging activities and connecting them.
  • Optional: a Get Metadata activity, if you want to decide based on the number of files.

Step 1: Add the If Condition activity to the pipeline

In the Azure Data Factory Studio, open your pipeline. In the Activities pane on the left, type If in the search box and drag the If Condition activity onto the canvas. On the General tab, give it a clear name, for example Check_Files, so the pipeline logic is easy to read.

Step 2: Define the true/false expression

Select the activity and open the Activities tab. In the Expression field, click Add dynamic content and write an expression that returns a boolean value. The ADF expression language always starts with @. A simple example, based on a pipeline parameter (which you define on the Parameters tab):

@greater(pipeline().parameters.numeroFicheiros, 0)

This expression is true when the numeroFicheiros parameter is greater than zero. You can also compare text — for example, running the true branch only in the production environment:

@equals(pipeline().parameters.ambiente, 'prod')

You can also combine conditions with the and, or and not functions for more complete rules.

Step 3: Build the True branch

Still on the Activities tab, click the pencil icon in the True section (Edit activities). The canvas switches to a container where you place the activities that should run when the condition is true. Drag, for example, a Copy data activity to copy the files. To go back to the main pipeline, use the breadcrumb trail at the top of the canvas.

Step 4: Build the False branch

Repeat the process in the False section: click the pencil and add the activities for when the condition is not met. A common pattern is to place a short Wait activity here, or one that just logs a message. You are not required to fill both branches — if you do not need the false case, you can leave it empty.

Step 5: A real example with Get Metadata

A very common use is to decide based on the contents of a folder. If you have a Get Metadata activity returning the childItems list, connect it before the If Condition and use this expression:

@greater(length(activity('Get Metadata1').output.childItems), 0)

This way, the true branch only runs when the folder has at least one file, avoiding unnecessary runs.

Watch out for one important limitation: you cannot place an If Condition activity (or a Switch) inside another If Condition or Switch. You can, however, use them inside a ForEach or Until.

How it looks in JSON

If you open the pipeline code view, the activity has this minimal shape, with the expression and the two lists ifTrueActivities and ifFalseActivities:

{
  "name": "Check_Files",
  "type": "IfCondition",
  "typeProperties": {
    "expression": {
      "value": "@greater(pipeline().parameters.numeroFicheiros, 0)",
      "type": "Expression"
    },
    "ifTrueActivities": [],
    "ifFalseActivities": []
  }
}

Verify the result

Click Debug to run the pipeline. In the Output pane, you see the If Condition activity and which branch ran. Test both cases: change the parameter value (or the folder contents) to force the true result first and then the false one, and confirm that the correct branch runs each time.

Conclusion

With the If Condition activity you gain control flow in your pipeline without writing code. From here, try combining it with the ForEach to decide inside a loop, or use the Switch activity when you have more than two possible paths. One final tip: always give your activities descriptive names, so the pipeline logic reads almost like a sentence. Which condition will you want to test first in your next pipeline?