Databricks & Lakehouse
Building Your First ETL Pipeline with Azure Data Factory
💡 A step-by-step guide — from empty resource group to a running pipeline that moves data from Blob storage into SQL, with monitoring…
💡 A step-by-step guide — from empty resource group to a running pipeline that moves data from Blob storage into SQL, with monitoring, retries, and best practices.
🚀 TL;DR (quick view)
Create an Azure Data Factory (ADF), define Linked Services (connections), author Datasets, build a Pipeline containing a Copy Activity (and optional Data Flow for transformations), test locally (Debug), publish, and monitor runs in ADF Monitor. Use CLI/portal or CI/CD for repeatability. (Microsoft Learn)
🎓 Skills You’ll Learn
ADF basics
Integration Runtimes
Linked Services
Datasets
Mapping Data Flows
CLI & automation
ETL design patterns
1. Why Azure Data Factory?
ADF is Microsoft’s cloud-native ETL/ELT orchestration service — a visual, managed platform to compose data movement and transformation activities across on-prem and cloud stores. It supports a huge list of connectors, scalable integration runtimes, and built-in monitoring, making it ideal for modern data engineering. (Microsoft Learn)
2. Plan your pipeline (before you click)
A good pipeline starts on paper. For this tutorial we’ll implement a common pattern:
Source: Azure Blob Storage (CSV files)
Transform: (optional) Mapping Data Flow — simple column casting / cleanse
Sink: Azure SQL Database (or Azure Synapse dedicated SQL pool)
Trigger: Schedule or manual
Ops: Checkpointing via control table, retry policies, monitoring alerts

This architecture shows a simple Azure ETL workflow.
- Azure Blob Storage holds raw CSV files.
2. Azure Data Factory (ADF) orchestrates the ETL:
- Reads files from Blob (via Linked Service + Dataset)
- Optionally transforms using Mapping Data Flows
- Loads data into the target
3. Azure SQL Database serves as the sink where processed data lands.
Flow:
Blob Storage → ADF Linked Services → Pipeline (Copy/Data Flow) → Azure SQL Database
3. Prep — create resource group & data factory (CLI + Portal options)
CLI (fast reproducible)
# create resource group
az group create -n adf-rg -l eastus
# create data factory
az datafactory create -g adf-rg -n myDataFactory --location eastus(These commands use the az datafactory extension — the CLI will auto-install it if needed.) (Microsoft Learn)
Portal (GUI)
Portal → Create a resource → Analytics → Data Factory → fill subscription, resource group, name → Create. The Data Factory UI works best in Chrome or Edge. (Microsoft Learn)
4. Create the Integration Runtime (where compute runs)
- Azure IR (default) for cloud-to-cloud copy.
- Self-hosted IR for on-prem sources (install Windows/Linux agent).
Use the portal or CLI (az datafactory integration-runtime self-hosted create) to register. This lets ADF access local file shares or databases securely. (Microsoft Learn)
5. Linked Services → Datasets → Activities (core building blocks)
Linked Service (connection)
Create a linked service that stores connection info (SAS/key for Blob, connection string for Azure SQL). Example CLI pattern:
az datafactory linked-service create --factory-name myDataFactory -g adf-rg -n LS_AzureBlob --properties "@blob-linked-service.json"blob-linked-service.json is a JSON body defining type AzureBlobStorage and connection properties. (ADF UI also provides a guided creation flow.) (Microsoft Learn)

Dataset
A Dataset is a pointer to data inside a linked service (e.g., path pattern container/incoming/*.csv). Define a source dataset for the blobs and a sink dataset for the target SQL table.
Copy Activity
The Copy Activity moves data from source dataset → sink dataset. You can configure mapping, fault-tolerance (fault tolerance settings), and performance options (parallel copy, degree of copy concurrency). See Copy Activity docs for supported stores & best options. (Microsoft Learn)
6. Example — Minimal pipeline JSON (Copy Activity)
Below is a simplified pipeline JSON you can use with az datafactory pipeline create --pipeline @pipeline.json. Replace placeholders (<...>) before running.
{
"name": "CopyBlobToSqlPipeline",
"properties": {
"activities": [
{
"name": "CopyFromBlobToSql",
"type": "Copy",
"inputs": [{ "referenceName": "BlobDataset", "type": "DatasetReference" }],
"outputs": [{ "referenceName": "SqlDataset", "type": "DatasetReference" }],
"typeProperties": {
"source": { "type": "BlobSource", "recursive": true },
"sink": { "type": "SqlSink", "preCopyScript": "TRUNCATE TABLE staging.transactions;" }
},
"policy": {
"retry": 3,
"retryIntervalInSeconds": 30,
"timeout": "00:30:00"
}
}
]
}
}Where to replace: BlobDataset and SqlDataset names must match the dataset resources you created; preCopyScript is optional. Use the CLI to create the pipeline JSON and run it. (Microsoft Learn)
7. Optional: Mapping Data Flows (transform without code)
If you need transformations (type casts, dedup, derived columns), use Mapping Data Flows — ADF’s visual Spark-powered transforms. Design in the UI, debug with sampling, and then wire into pipeline as a Data Flow Activity. Data Flows scale automatically and don’t require you to manage Spark clusters. (Microsoft Learn)
💰 Cost of Mapping Data Flows (Important for New Users)
Mapping Data Flows run on Azure Integration Runtime clusters (Spark-based).
You pay for Data Flow Cluster Compute + Execution Time.
Typical Costs:
- Data Flow Debug Session: ~$0.36–$0.55 per vCore-hour
- Data Flow Execution (Production runs): ~$0.72–$1.10 per vCore-hour
- Minimum billing duration: 1 minute
- Clusters auto-scale between 8–32 vCores depending on workload
- Larger flows (joins, aggregations, large files) scale toward upper range
Rule of thumb:
Small datasets → ₹15–30 per run
Medium datasets → ₹60–120 per run
Heavy nightly ETL with complex Data Flows → ₹4,000–₹8,000 per month
Cost-saving tips:
- Use Debug Mode only when needed
- Prefer Copy Activity when no transformations are required
- Parameterize and reuse Data Flows
- Turn on auto-termination in debug sessions
8. Test locally (Debug) → Publish → Trigger
- In ADF Studio, use Debug to run pipeline interactively on sample files.
- When green, Publish to make pipelines available for triggers.
- Create a Trigger (Schedule, Tumbling Window, or Event-based). Tumbling window triggers are useful for correctness and re-runs (stateful windows). (Microsoft Learn)
9. Monitor & Troubleshoot
ADF provides a Monitor UI showing pipeline runs, activity runs, and logs. For deeper ops, integrate with Azure Monitor / Log Analytics for alerting and diagnostics. Use pipeline-run logs, activity-run logs, and diagnostic settings to investigate failures and re-run individual activities. (Microsoft Learn)
🧰 Common Errors & Fixes (Beginner Guide)
❌ Error: “Authentication failed for Linked Service”
Fix:
- Re-generate SAS token
- Ensure Key Vault permissions allow get & list
- Check if connection string uses correct database name
❌ Error: “File not found.”
Fix:
- Verify container name & folder path
- Ensure wildcard patterns like *.csv match actual file names
- Enable recursive if files are in nested folders
❌ Error: “Schema mismatch between source and sink.”
Fix:
- Add explicit column mapping
- Use Data Flow to cast datatypes
- Ensure sink table columns match CSV headers
❌ Error: “Timeout in Copy Activity.”
Fix:
- Increase timeout in policy
- Reduce file size or split large files
- Enable parallel copy for better throughput
❌ Error: “Self-Hosted IR is offline.”
Fix:
- Restart IR service
- Check machine firewall & outbound connectivity
- Re-authenticate with Data Factory access key
Quick checks when a run fails:
- Check linked service credentials/expiry (SAS tokens).
- Inspect copy activity error details (file path, permission, schema mismatch).
- Rerun failed activity instead of whole pipeline (use partial rerun patterns).
10. Production Hardenings & Best Practices
- Parameterize everything — storage paths, table names, batch date → reuse pipelines.
- Metadata-driven pipelines — master orchestrator + control table to loop over object list (helps scale to many tables/files). (Microsoft Learn)
- Use checkpoints / watermarking in source systems (or employ CDC patterns) for incremental loads.
- Persist checkpoints (e.g., control table in SQL) to avoid reprocessing.
- Retries & timeouts — set reasonable retry policy and alerts.
- Secure secrets using Key Vault-linked services (do not embed credentials).
- CI/CD — export ARM templates or use Git integration for factory objects.
11. Real-world example (retail ETL)
A retail company wants nightly ingestion of POS CSVs into an Azure SQL warehouse:
- Files uploaded to Blob container
incoming/daily/YYYYMMDD/. - An ADF Tumbling Window trigger runs every hour and processes files for the previous hour.
- Copy Activity loads into a staging table; Mapping Data Flow cleans data (trim strings, cast numeric, dedupe).
- Stored Proc merges staging into dimensional model; success triggers update to reporting dataset.
Using ADF monitoring + Log Analytics they alert on any failed runs and rerun specific failed windows — lowering MTTR and preventing full reprocessing. (Pattern: control table + tumbling windows + checkpointing.) (Azure Documentation)
12. CI/CD & Automation
Export your factory assets as ARM templates or connect ADF to Git (Azure DevOps or GitHub). Use az datafactory pipeline create to deploy pipeline JSON in automation. For production, store checkpoints and transient state in durable stores (Azure SQL, Blob, or Delta). (Microsoft Learn)
13. Quick Troubleshooting Checklist
- Authentication errors → check Key Vault & service principal permissions.
- Schema mismatch → add explicit mapping or Data Flow type cast.
- Slow copy performance → enable parallel copy, tune copy concurrency.
- Large file load failures → increase
timeoutor break data into chunks.
🔧 Debugging These Failures in Practice
If you’re hitting errors like these in production — Airflow failures, Spark OOM,Kafka SSL issues — I built a tool to help.
Paste your broken code + error logs into Vayu and get back:
→ Exact root cause
→ Before/After code fix
→ Confidence score (HIGH/MEDIUM/LOW)
Free to try at vayufix.com
No signup needed for first 3 fixes.
14. Recap — The Minimal Checklist to Ship
- Resource group & Data Factory created. (Microsoft Learn)
- Integration Runtime configured (self-hosted if needed).
(Microsoft Learn) - Linked Services created (Blob + SQL). (Microsoft Learn)
- Datasets defined (source pattern + sink).
- Pipeline JSON with Copy Activity (retries, pre/post actions).(Microsoft Learn)
- Debugged, Published, Triggered, and Monitored. (Microsoft Learn)
🔜 Next in Series
👉 Coming up next: “Databricks 101: Spark in the Cloud”
We’ll break down how Databricks works under the hood — clusters, notebooks, Delta Lake, optimized autoscaling, and how it turns Spark into a fully managed, cloud-native analytics engine.
💡 Think of it as the upgrade path from ADF pipelines to a complete end-to-end Lakehouse platform.
🔔 Follow for More
If you found this helpful, follow TheDataForge for your daily Spark in Data Engineering & Machine Learning ⚡
Let’s connect — I post daily Big Data & Spark insights at DataForgeX on X.
💬 Comment below — what source & sink combo do you want a ready-made ADF template for?
Sources & Further Reading
- Quickstart: create a data factory (Azure CLI)
- Copy activity overview (ADF & Synapse)
- Use the Azure portal to create a data factory pipeline
- Linked services reference
- Monitor & manage pipelines in ADF
🏷️ Tags
#AzureDataFactory #Azure #DataEngineering #BigData #ETL #DataPipelines #AzureBlobStorage #AzureSQL #CloudComputing #DataIntegration