The nightly master pipeline
π¦Load Supplier Files + Incremental Orders
Run in parallel (Execute Pipeline)
πClean Orders
Data flow, only if both succeeded
π¨On failure
Alert webhook β Fail activity
{
"name": "PL_Master_Daily",
"properties": {
"description": "The nightly run: load files and app orders in parallel, then clean them. Alert if a load fails.",
"activities": [
{
"name": "Load Supplier Files",
"type": "ExecutePipeline",
"typeProperties": {
"pipeline": {
"referenceName": "PL_Load_Supplier_Folder",
"type": "PipelineReference"
},
"waitOnCompletion": true
}
},
{
"name": "Incremental Orders",
"type": "ExecutePipeline",
"typeProperties": {
"pipeline": {
"referenceName": "PL_Incremental_Orders",
"type": "PipelineReference"
},
"waitOnCompletion": true,
"parameters": {
"tableName": "orders"
}
}
},
{
"name": "Clean Orders",
"type": "ExecuteDataFlow",
"dependsOn": [
{
"activity": "Load Supplier Files",
"dependencyConditions": [
"Succeeded"
]
},
{
"activity": "Incremental Orders",
"dependencyConditions": [
"Succeeded"
]
}
],
"policy": {
"timeout": "0.02:00:00",
"retry": 1,
"retryIntervalInSeconds": 120
},
"typeProperties": {
"dataflow": {
"referenceName": "DF_Clean_Orders",
"type": "DataFlowReference",
"datasetParameters": {
"RawOrders": {
"folderPath": "raw/supplier_orders"
},
"CuratedOrders": {
"folderPath": "curated/orders"
}
}
},
"compute": {
"coreCount": 8,
"computeType": "General"
},
"traceLevel": "Fine"
}
},
{
"name": "Alert Supplier Load Failed",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Load Supplier Files",
"dependencyConditions": [
"Failed"
]
}
],
"typeProperties": {
"method": "POST",
"url": {
"value": "@pipeline().globalParameters.alertWebhookUrl",
"type": "Expression"
},
"headers": {
"Content-Type": "application/json"
},
"body": {
"value": "@concat('{\"pipeline\":\"', pipeline().Pipeline, '\",\"runId\":\"', pipeline().RunId, '\",\"failedStep\":\"Load Supplier Files\",\"error\":\"', replace(activity('Load Supplier Files').error.message, '\"', ''''), '\"}')",
"type": "Expression"
}
}
},
{
"name": "Mark Run Failed",
"type": "Fail",
"dependsOn": [
{
"activity": "Alert Supplier Load Failed",
"dependencyConditions": [
"Succeeded"
]
}
],
"typeProperties": {
"message": {
"value": "@concat('Supplier load failed: ', activity('Load Supplier Files').error.message)",
"type": "Expression"
},
"errorCode": "SUPPLIER_LOAD_FAILED"
}
}
]
}
}Dependency conditions: the four arrows
| Condition | Runs when the upstream activity... | Typical use |
|---|---|---|
| Succeeded (green) | succeeded | Normal flow |
| Failed (red) | failed | Alerts, clean-up, fallback |
| Completed (blue) | succeeded or failed | Always log the result |
| Skipped (grey) | didn't run | Handle branches that were bypassed |
With several dependencies, all must be met (Clean Orders needs both loads to succeed). Listing several conditions on one dependency means any of them.
Run it: a normal night and a bad night
We ran the master pipeline twice: once with everything succeeding, once telling the framework that Load Supplier Files failed with a file-not-found error. A small helper copies the error into activity('...').error, which the framework doesn't record by itself yet:
from data_factory_testing_framework import TestFramework, TestFrameworkType
from data_factory_testing_framework.exceptions import NoRemainingPipelineActivitiesMeetDependencyConditionsError
from data_factory_testing_framework.state import (DependencyCondition, PipelineRunState,
RunParameter, RunParameterType)
# The framework records an activity's output but not its error, so we copy
# output["error"] to activity('...').error ourselves (a small test helper).
_record = PipelineRunState.add_activity_result
def _record_with_error(self, name, status, output=None):
_record(self, name, status, output)
if isinstance(output, dict) and "error" in output:
for result in self.activity_results + self.scoped_activity_results:
if result.activity_name == name:
result.error = output["error"]
PipelineRunState.add_activity_result = _record_with_error
tf = TestFramework(framework_type=TestFrameworkType.DataFactory, root_folder_path="shopkart-adf")
params = [
RunParameter(RunParameterType.Global, "alertWebhookUrl", "https://example.com/hooks/shopkart-alerts"),
RunParameter(RunParameterType.System, "Pipeline", "PL_Master_Daily"),
RunParameter(RunParameterType.System, "RunId", "a91f-0622"),
]
def run(supplier_load_fails):
pipeline = tf.get_pipeline_by_name("PL_Master_Daily")
try:
for activity in tf.evaluate_pipeline(pipeline, params):
if activity.name == "Load Supplier Files" and supplier_load_fails:
activity.set_result(DependencyCondition.Failed, {"error": {
"message": "Operation on target Copy CSV to Lake failed: ErrorCode=UserErrorFileNotFound"}})
print("β", activity.name, "(failed)")
continue
print("β", activity.name, f"[{activity.type}]")
if activity.type == "WebActivity":
print(" POST", activity.type_properties["url"].result)
print(" body", activity.type_properties["body"].result)
if activity.type == "Fail":
print(" message:", activity.type_properties["message"].result)
except NoRemainingPipelineActivitiesMeetDependencyConditionsError:
print("β nothing else can run: the remaining activities' conditions were never met (skipped)")
print("=== Normal night ==="); run(False)
print("=== Supplier load fails ==="); run(True)=== Normal night ===
β Load Supplier Files [ExecutePipeline]
β Incremental Orders [ExecutePipeline]
β Clean Orders [ExecuteDataFlow]
β nothing else can run: the remaining activities' conditions were never met (skipped)
=== Supplier load fails ===
β Load Supplier Files (failed)
β Incremental Orders [ExecutePipeline]
β Alert Supplier Load Failed [WebActivity]
POST https://example.com/hooks/shopkart-alerts
body {"pipeline":"PL_Master_Daily","runId":"a91f-0622","failedStep":"Load Supplier Files","error":"Operation on target Copy CSV to Lake failed: ErrorCode=UserErrorFileNotFound"}
β Mark Run Failed [Fail]
message: Supplier load failed: Operation on target Copy CSV to Lake failed: ErrorCode=UserErrorFileNotFoundRead the bad night carefully:
Incremental Ordersstill ran: it doesn't depend on the supplier load.Clean Ordersdid not run: one of its two dependencies failed.- The alert posted the pipeline name, run ID and the real error message to the webhook.
Mark Run Failedthen failed the run on purpose, with a clear message.
The βsucceeded but failedβ trap
Retries and timeouts
| Policy setting | Our values | Why |
|---|---|---|
| retry | 2 (Copy), 1 (data flow), 3 (hourly window) | Survive temporary errors |
| retryIntervalInSeconds | 60β300 | Give the source time to recover |
| timeout | 1β2 hours | Stop stuck activities (the default is 12 hours) |
| secureInput / secureOutput | on for secrets | Hide values from monitoring logs |
Monitoring
| Tool | Gives you |
|---|---|
| Monitor hub | Pipeline, activity and trigger runs for 45 days; rerun, rerun from failed activity; Gantt view |
| Activity output | Copy details (rows, throughput, DIUs), errors, durations |
| Azure Monitor metrics + alerts | Failed runs, run durations; email/SMS/Teams through action groups |
| Diagnostic settings β Log Analytics | Long history, KQL queries, dashboards across factories |
| Annotations / user properties | Tag runs (e.g. table name) so you can filter them in monitoring |
π― Interview questions on this topic
Try to answer out loud first, then tap to check.
Q1How do you handle errors in ADF pipelines?Fresher+
Q2Implement try-catch in ADF.1β3 yrs+
Q3How would you send an alert with the error message?1β3 yrs+
Q4A pipeline intermittently fails with timeouts on the source database at 2 a.m. What do you do?3+ yrs+
Key takeaways
- βRetry the temporary, alert on the real, fail clearly.
- βOur failure path posted the true error, then failed the run.
- βRemember: handled failures show as success without a Fail activity.
- βMonitor centrally and alert before users notice.
Frequently asked questions
Why does my pipeline show Succeeded even though an activity failed?
If a failure is handled (an activity on its 'Upon Failure' path runs and succeeds), ADF treats the pipeline as successful, because the leaf activities succeeded. To mark the run failed after alerting, add a Fail activity at the end of the failure path.
Retry policy or rerun?
Retries (policy.retry and retryIntervalInSeconds) handle temporary problems automatically: network blips, throttling, a busy database. Reruns (from the Monitor hub, including 'rerun from failed activity') are for after you've fixed the real cause.
How long does ADF keep run history?
The Monitor hub keeps pipeline run data for 45 days. For longer history, queries and alerts on details, send diagnostic logs to a Log Analytics workspace with Azure Monitor diagnostic settings.
How do I get alerted when a pipeline fails?
Two common ways: Azure Monitor alerts on the factory's 'Failed pipeline runs' metric (email, SMS, Teams via action groups), or an alert step inside the pipeline (a Web activity calling a Logic App or Teams webhook) with details like run ID and error message.
π§ Quick check: monitoring and errors
1. An activity should run only when 'Load Supplier Files' fails. Dependency condition?
2. The alert ran after the failure. Why does our pipeline also have a Fail activity?
3. Where is the failed activity's message?
4. On a normal night, what happened to the alert activities?
Checking your accessβ¦