🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Batch Pipeline Architecture: ADLS → ADF → Synapse

Azure Data EngineeringBatch Pipeline⭐ Premium

Prerequisites

  • !How a lake zones raw, curated and serving data
  • !Basic idea of what an orchestration pipeline does
  • !SQL bulk load operations such as COPY

What You'll Learn

  • 1Break a batch pipeline into stages with explicit contracts between them
  • 2Copy incrementally with watermarks and explain why they beat full extracts
  • 3Load into a dedicated SQL pool without lock contention or permanent table bloat
  • 4Design retries and alerting that respect a morning reporting SLA
  • 5Decide which stage belongs in ADF data flows versus Spark

The shape of a nightly batch

A batch pipeline is a sequence of stages that run on a schedule, each with a defined input, output and success condition. The three-stage model that scales well is extract into the landing zone, transform into the curated zone, and load into the serving layer. Between stages there is a contract: a file count, a row count, a schema version, or a control-table row that says the previous stage completed.

The reason contracts matter is blast radius. When the load stage fails, the transformation output is already complete and valid, so the recovery is to re-run one stage rather than the whole night. Pipelines that treat the night as one undifferentiated job force a full restart, which is exactly what you cannot afford at 05:40 with a 06:00 deadline.

Scheduling is a design decision, not a default. A pipeline feeding a report read at 08:00 in London should finish before 07:00 London time, which may be overnight in the region where the source system is least loaded. Staggering dependent pipelines by their true duration, rather than by round clock offsets, prevents the classic cascade where one late stage delays everything downstream by an hour.

StagePrimary riskSuccess signalRecovery action
ExtractSource unavailable or partial readFile count and checksum match control rowRe-run extract only
TransformBad records or schema driftRow counts and assertion tests passRe-run from raw, no source load
LoadLock contention or duplicate keysTarget count delta equals curated deltaTruncate partition, re-run load
PublishStale metric or failed refreshDashboard timestamp updatedRe-run publish step alone

Incremental copy with watermarks

Extracting an entire source every night works until the source is large, then it fails on duration and on the load you place on the operational system. An incremental copy reads only rows changed since the last successful run, tracked by a watermark column such as a modified timestamp or a monotonically increasing key.

Data Factory makes this a first-class pattern: a watermark table stores the last value per source, the copy activity reads rows greater than that value, and an after-copy activity writes the new maximum back. The ordering is what matters. Store the watermark only after the copy succeeds, otherwise a failed copy advances the watermark and those rows are never read again.

{
  "name": "copy_orders_incremental",
  "type": "Copy",
  "typeProperties": {
    "source": {
      "type": "SqlServerSource",
      "sqlReaderQuery": "SELECT OrderId, ModifiedAt, Status, Amount FROM dbo.Orders WHERE ModifiedAt > '@{pipeline().parameters.lastWatermark}'"
    },
    "sink": {
      "type": "AzureBlobFSWriteSettings",
      "formatSettings": { "type": "ParquetSettings" }
    },
    "enableStaging": true,
    "translator": { "type": "TabularTranslator" }
  },
  "dependsOn": [
    { "activity": "lookup_last_watermark", "dependencyConditions": ["Succeeded"] }
  ]
}

Two failure modes follow from this design. Rows updated with a timestamp set by the application can arrive out of order, so a safety overlap of several minutes plus an idempotent overwrite of the destination partition is standard practice. And rows with a null watermark column are never selected, so the query must handle nulls explicitly or exclude that column from the contract.

Turning files into tables

Landing Parquet files in the lake is not the same as making them queryable. In a dedicated SQL pool the usual path is an external table over the files, then a COPY or CTAS into an internal table. In a serverless SQL endpoint, the files can be queried directly, which is often enough for exploration but not for performance-sensitive serving.

The operational trap is permanent table bloat. Repeated CTAS operations into the same table create a scatter of small distributions and eventually require reclamation. The disciplined pattern is to load into a staging table, then move data with an INSERT SELECT or a partition switch, and finally rebuild statistics on the affected partition.

-- Stage, move, then refresh statistics
CREATE TABLE stg.fact_order
WITH (
    DISTRIBUTION = HASH(order_id),
    CLUSTERED COLUMNSTORE INDEX
)
AS SELECT * FROM ext.fact_order
WHERE dt = '2026-10-11';

-- Replace the partition atomically where supported
DELETE FROM sales.fact_order WHERE dt = '2026-10-11';
INSERT INTO sales.fact_order
SELECT * FROM stg.fact_order;

UPDATE STATISTICS sales.fact_order WITH FULLSCAN;
DROP TABLE stg.fact_order;

Distribution choice deserves more attention than it usually gets. Hash distribution on the join key co-locates related rows so joins do not shuffle across the whole cluster. Round-robin suits staging tables where no join happens yet. Replicate suits small dimensions used by every node, because the cost is a copy per distribution node rather than a shuffle per query.

Retry policy that respects the clock

Not every failure deserves a retry, and not every retry deserves to be fast. Connection resets and throttling responses are transient and benefit from backoff. Schema mismatches and constraint violations are permanent and will fail identically on the third attempt, wasting twenty minutes you did not have.

The practical policy is per-activity retries with exponential backoff for transient categories, a hard pipeline timeout set below the gap to the next dependent job, and an alert channel that reaches a human on the first failure rather than the last. A pipeline that retries for three hours and then fails at 07:30 is worse than one that fails fast at 04:00 and pages someone.

{
  "policy": {
    "timeout": "0.08:00:00",
    "retry": 3,
    "retryIntervalInSeconds": 60,
    "secureOutput": false,
    "secureInput": false
  },
  "dependencies": [
    { "activity": "load_serving", "dependencyConditions": ["Succeeded"] }
  ]
}

Note that timeout is expressed in the ISO duration format and applies per activity. Setting a generous timeout with three retries can still exceed your SLA, so compute the worst case: timeout multiplied by attempts plus backoff must fit inside the window before the report is read.

When to move a stage to Spark

ADF data flows are excellent for set-based transformations over structured sources with modest complexity: joins, aggregations, derived columns and slowly changing dimensions. They are configured visually or as mapping data flows, they execute on a managed Spark cluster, and they are easy for analysts to own.

The move to a Databricks notebook is justified when the logic needs libraries, complex windowing, machine learning, or file-level operations that data flows express awkwardly. The cost of that move is operational: you now own a notebook, a cluster policy and a job definition instead of a pipeline artifact.

A common compromise is to keep extraction and light conformance in ADF, push heavy transformation to Databricks, and let ADF orchestrate both. That keeps scheduling in one place while allowing each stage to use the engine it is genuinely good at.

Monitoring the pipeline as a product

Three signals are enough to run a batch pipeline well: stage duration against baseline, row count delta against expectation, and freshness of the serving table relative to its schedule. Each maps to a distinct failure. Duration spikes mean the source or the cluster degraded. Row count drift means upstream data changed or a filter is wrong. Staleness means the pipeline did not run at all, which is the failure that monitoring focused on errors frequently misses.

Azure Data Factory publishes pipeline-run metrics to Azure Monitor, and alert rules on those metrics close the loop. Pair them with a query on the control table that asserts the serving table's maximum load timestamp, because that is the question the business actually asks.

Common Mistakes

Advancing the watermark before confirming the copy succeeded

Fix: Write the new watermark in an after-copy step gated on success, and treat a failed copy as leaving the watermark untouched

Setting one generous retry policy across all activities

Fix: Retry transient categories with backoff and fail fast on schema or constraint errors

Repeatedly running CTAS into a production table

Fix: Load into staging, move into the target, then update statistics and drop the staging table

Alerting only on pipeline failure

Fix: Alert on staleness and row-count drift too, since a skipped run reports no error at all

Best Practices

  • Give every stage an explicit contract recorded in a control table
  • Re-run from the failed stage rather than restarting the night
  • Choose distribution and indexing based on join and filter patterns, not defaults
  • Keep the worst-case retry budget smaller than the gap to the next dependent job

Interview Questions

Q1: How does a watermark-based incremental copy work?

A stored value marks the last processed row key or timestamp, the copy selects rows beyond it, and the value is updated only after the copy succeeds so a failure cannot skip data.

Q2: Why stage data before loading into a dedicated SQL pool?

It isolates transformation errors from the serving table, allows distribution and statistics to be set deliberately, and avoids repeated CTAS operations that fragment the table.

Q3: How do you decide between an ADF data flow and a Databricks notebook?

Data flows suit set-based transformations that analysts should own. Notebooks are justified by libraries, complex windowing, machine learning or file-level operations, at the cost of owning cluster and job configuration.

Q4: What should the pipeline timeout be relative to the SLA?

Tight enough that the worst case of all retries still finishes before the next dependent job or report read, so failure surfaces early enough for a human to act.

Q5: Which distribution is appropriate for a fact table joined to dimensions?

Hash distribution on the join key, so related rows are co-located and joins do not shuffle across every distribution node.

Key Takeaways

  • Stage the night into extract, transform and load with contracts between them
  • Watermarks give cheap increments only when they are written after success
  • Staging plus move keeps serving tables clean and statistics valid
  • Retry budgets must fit inside the SLA window, not just look generous
  • Freshness monitoring catches the failures that error alerting never sees
🔒

Premium Content

Batch Pipeline Architecture: ADLS → ADF → Synapse

You've previewed the first section. Unlock this full lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
💼Interview Prep
📜Certificates
🤝Community Access

Already a member? Log in

CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-12

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Advertisement