Use Microsoft Azure Data Factory Operators
You can use Airflow in Datacoves to trigger a Microsoft Azure Data Factory pipeline. This guide will walk you through the configuration process.
Prerequisites
- You will need to set up a Microsoft Entra Application.
- Assign the
Data Factory Contributorrole to your Microsoft Entra Application. You can do this by heading into Resource Groups and then following these instructions. - Collect the following values from your ADF account, more information on where to find these items in the next section:
DATA_FACTORY_NAMERESOURCE_GROUP_NAMESUBSCRIPTION_IDAPPLICATION_CLIENT_IDTENANT_IDCLIENT_SECRET
How to get the ADF information
Step 1: Log in to your Microsoft Azure console and navigate to the Data Factories service.
Step 2: Copy the DATA_FACTORY_NAME for the factory which holds your data pipeline.
Step 3: Open the factory and copy the RESOURCE_GROUP_NAME, and the SUBSCRIPTION_ID from the Overview tab
Step 4: Browse to Entra ID > App registrations and open your application, or register a new one. On the application's Overview page, copy the Application (client) ID, which is the APPLICATION_CLIENT_ID, and the Directory (tenant) ID, which is the TENANT_ID.
Step 5: In the application, select Certificates & secrets > Client secrets > New client secret. After you add it, copy its Value. This is the CLIENT_SECRET. Azure shows the value only once, so copy it right away.
Create a Microsoft Azure Data Factory Connection in Airflow
Step 1: In Datacoves, a user with the securityadmin role opens Airflow's connections. The menu depends on your environment's Airflow version.
- Airflow 2
- Airflow 3
Go to the Admin -> Connections menu.

In the left sidebar, click Admin and then Connections.

Step 2: Create a new connection. The form depends on your environment's Airflow version.
- Airflow 2
- Airflow 3
Create a new connection using the following details.
-
Connection Id:
azure_data_factory_default- this name will be used in the Airflow DAG and is the default name used by the ADF Operator -
Connection Type:
Azure Data Factory -
Client ID: Your
APPLICATION_CLIENT_ID -
Secret: Your
CLIENT_SECRET -
Tenant ID: Your
TENANT_ID -
Factory Name: Your
DATA_FACTORY_NAME -
Resource Group Name: Your
RESOURCE_GROUP_NAME -
Subscription ID: Your
SUBSCRIPTION_ID
Replace the values in the screenshot below with the actual values found above.

Click Add Connection and fill in:
- Connection ID:
azure_data_factory_default- this name will be used in the Airflow DAG and is the default name used by the ADF Operator - Connection Type:
Azure Data Factory
Under Standard Fields, the connection's login and password:
- Client ID (login): Your
APPLICATION_CLIENT_ID - Secret (password): Your
CLIENT_SECRET

Open Extra Fields JSON. The editor already lists the Azure Data Factory fields with null values; replace them with yours. Leave managed_identity_client_id and workload_identity_tenant_id as null when you authenticate with a client secret.
{
"tenantId": "<TENANT_ID>",
"subscriptionId": "<SUBSCRIPTION_ID>",
"resource_group_name": "<RESOURCE_GROUP_NAME>",
"factory_name": "<DATA_FACTORY_NAME>",
"managed_identity_client_id": null,
"workload_identity_tenant_id": null
}

After you save it, the connections list shows the connection type by its id, azure_data_factory.

Example DAG
Change "myTestPipeline" in adf_pipeline("myTestPipeline") to the name of your pipeline. The DAG reads the Resource Group Name and Factory Name from the azure_data_factory_default connection, so you don't set them in the code.
Once you have configured your Azure Data Factory connection, you are ready to create your DAG. Head into the Transform tab to begin writing your DAG inside orchestrate/dags.
- Airflow 2
- Airflow 3
"""
## Run an Azure Data Factory pipeline
Starts an ADF pipeline, then waits for it with a deferrable sensor. While the sensor waits, it runs in
the Airflow triggerer instead of holding a worker slot. The sensor fails if the pipeline run fails.
When the pipeline succeeds, a dbt task runs.
Requires `apache-airflow-providers-microsoft-azure` and an `Azure Data Factory` connection with the
Client ID, Secret, Tenant ID and Subscription ID of a service principal that has the
`Data Factory Contributor` role on the factory's resource group.
Set Resource Group Name and Factory Name in the connection too.
"""
from datetime import timedelta
import pendulum
from airflow.decorators import dag, task, task_group
from airflow.providers.microsoft.azure.operators.data_factory import AzureDataFactoryRunPipelineOperator
from airflow.providers.microsoft.azure.sensors.data_factory import AzureDataFactoryPipelineRunStatusSensor
# The operator and sensor require resource_group_name and factory_name, but None makes the
# hook use the Resource Group Name and Factory Name set in the connection
ADF_ARGS = {
"azure_data_factory_conn_id": "azure_data_factory_default",
"resource_group_name": None,
"factory_name": None,
}
@dag(
doc_md=__doc__,
start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
schedule="0 0 1 */12 *", # once a year, Jan 1 at midnight UTC
catchup=False,
default_args={
"owner": "airflow",
"retries": 2,
"retry_delay": timedelta(minutes=5),
},
description="Trigger an Azure Data Factory pipeline, wait for it with a deferrable sensor, then run dbt",
tags=["extract_and_load"],
)
def run_adf_pipeline():
@task_group
def adf_pipeline(pipeline_name):
# Start the pipeline and return immediately; the run_id is pushed to XCom
run_pipeline = AzureDataFactoryRunPipelineOperator(
task_id="run_pipeline",
pipeline_name=pipeline_name,
# parameters={"my_param": "value"}, # only parameters the pipeline declares
wait_for_termination=False,
**ADF_ARGS,
)
# Wait for the run to finish in the triggerer
wait_for_pipeline = AzureDataFactoryPipelineRunStatusSensor(
task_id="wait_for_pipeline",
run_id=run_pipeline.output["run_id"],
deferrable=True,
poke_interval=60, # seconds between status checks
timeout=60 * 60 * 2, # fail if the run takes more than 2 hours
**ADF_ARGS,
)
run_pipeline >> wait_for_pipeline
# Runs only after both tasks in the group succeed
@task.datacoves_dbt(
connection_id="main"
)
def run_dbt():
return "dbt debug"
adf_pipeline("myTestPipeline") >> run_dbt()
run_adf_pipeline()
"""
## Run an Azure Data Factory pipeline
Starts an ADF pipeline, then waits for it with a deferrable sensor. While the sensor waits, it runs in
the Airflow triggerer instead of holding a worker slot. The sensor fails if the pipeline run fails.
When the pipeline succeeds, a dbt task runs.
Requires `apache-airflow-providers-microsoft-azure` and an `Azure Data Factory` connection with the
Client ID, Secret, Tenant ID and Subscription ID of a service principal that has the
`Data Factory Contributor` role on the factory's resource group.
Set Resource Group Name and Factory Name in the connection too.
"""
from datetime import timedelta
import pendulum
from airflow.sdk import dag, task, task_group
from airflow.providers.microsoft.azure.operators.data_factory import AzureDataFactoryRunPipelineOperator
from airflow.providers.microsoft.azure.sensors.data_factory import AzureDataFactoryPipelineRunStatusSensor
# The operator and sensor require resource_group_name and factory_name, but None makes the
# hook use the Resource Group Name and Factory Name set in the connection
ADF_ARGS = {
"azure_data_factory_conn_id": "azure_data_factory_default",
"resource_group_name": None,
"factory_name": None,
}
@dag(
doc_md=__doc__,
start_date=pendulum.datetime(2025, 1, 1, tz="UTC"),
schedule="0 0 1 */12 *", # once a year, Jan 1 at midnight UTC
catchup=False,
default_args={
"owner": "airflow",
"retries": 2,
"retry_delay": timedelta(minutes=5),
},
description="Trigger an Azure Data Factory pipeline, wait for it with a deferrable sensor, then run dbt",
tags=["extract_and_load"],
)
def run_adf_pipeline():
@task_group
def adf_pipeline(pipeline_name):
# Start the pipeline and return immediately; the run_id is pushed to XCom
run_pipeline = AzureDataFactoryRunPipelineOperator(
task_id="run_pipeline",
pipeline_name=pipeline_name,
# parameters={"my_param": "value"}, # only parameters the pipeline declares
wait_for_termination=False,
**ADF_ARGS,
)
# Wait for the run to finish in the triggerer
wait_for_pipeline = AzureDataFactoryPipelineRunStatusSensor(
task_id="wait_for_pipeline",
run_id=run_pipeline.output["run_id"],
deferrable=True,
poke_interval=60, # seconds between status checks
timeout=60 * 60 * 2, # fail if the run takes more than 2 hours
**ADF_ARGS,
)
run_pipeline >> wait_for_pipeline
# Runs only after both tasks in the group succeed
@task.datacoves_dbt(
connection_id="main"
)
def run_dbt():
return "dbt debug"
adf_pipeline("myTestPipeline") >> run_dbt()
run_adf_pipeline()
Understanding the Airflow DAG
- Understand how to authenticate with ADF.
- The DAG makes use of the AzureDataFactoryRunPipelineOperator to start the Azure Data Factory pipeline. With
wait_for_termination=Falsethe task finishes as soon as ADF creates the run and pushes itsrun_idto XCom. - To pass values to the pipeline, uncomment
parameters. Use only parameters that your pipeline declares. - The
AzureDataFactoryPipelineRunStatusSensorwaits for thatrun_id. Withdeferrable=True, the wait runs in the Airflow triggerer instead of holding a worker slot. It checks the run everypoke_intervalseconds (60) and fails if the pipeline run fails, is cancelled, or takes longer thantimeout(2 hours). - Both tasks are in a reusable task group,
adf_pipeline, so you can call it once per pipeline. run_dbtruns only after the pipeline succeeds. Replacedbt debugwith the dbt command you need. See Run dbt for more on thedatacoves_dbtdecorator.