Automated Azure Data Factory Mapping Data Flow Deployment and Employee CSV Transformation Using Terraform
- Provision Azure resources using Terraform: resource group, Blob Storage, Data Factory, and managed identity permissions.
- Upload the sample employee CSV to the
raw/input/Blob location. - Deploy the Blob linked service, source and sink datasets, Mapping Data Flow, and pipeline from version-controlled JSON.
- Calculate
salary_with_bonusas a 10% increase, filter employees withage > 25, and select the required columns. - Execute the pipeline and validate the expected three-row CSV in
clean/output/. - Monitor execution and clean up lab resources when finished.
flowchart LR
RAW["Azure Blob Storage<br/>raw/input/employees.csv"]
ADF["ADF Pipeline<br/>pl_employee_transform"]
FLOW["Mapping Data Flow<br/>df_employee_transform<br/>Azure IR / Spark"]
CLEAN["Azure Blob Storage<br/>clean/output/"]
ADF -->|"ExecuteDataFlow activity"| FLOW
RAW -->|"Read CSV"| FLOW
FLOW -->|"Write transformed CSV"| CLEAN
Transformation: Source β Derived Column (salary_with_bonus = round(salary * 1.10, 2)) β Filter (age > 25) β Select β Sink.
Expected output: 3 records from 4 input records. Both Blob containers are in the same storage account. The ADF pipeline orchestrates the Data Flow; the Spark runtime reads and writes Blob data.
Detailed architecture and sequence diagrams Β· Azure deployment commands
Prerequisites: Azure CLI, Terraform 1.6+, Azure subscription access, and permissions to create resources and assign RBAC roles. Clone the repository and run these commands from its root.
az login
az account set --subscription "08b7b8d4-af42-4972-9517-11ea256ea068"
az account show --query "{name:name,id:id}" -o tablecd terraform
cp terraform.tfvars.example terraform.tfvars
terraform init
terraform fmt -check
terraform validate
terraform plan -out=tfplan
terraform apply tfplan
terraform outputThe Terraform configuration uploads sample-data/employees.csv and creates the Blob containers, managed identity role assignment, linked service, datasets, Mapping Data Flow, and pipeline. Verified 1 November 2026: 13 resources deployed successfully in centralindia.
RG=$(terraform output -raw resource_group_name)
FACTORY=$(terraform output -raw data_factory_name)
STORAGE=$(terraform output -raw storage_account_name)
RUN_ID=$(az datafactory pipeline create-run \
--resource-group "$RG" \
--factory-name "$FACTORY" \
--name pl_employee_transform \
--query runId -o tsv)
echo "Pipeline run ID: $RUN_ID"az datafactory pipeline-run show \
--resource-group "$RG" \
--factory-name "$FACTORY" \
--run-id "$RUN_ID" \
--query "{status:status,message:message}" -o json
az datafactory activity-run query-by-pipeline-run \
--resource-group "$RG" \
--factory-name "$FACTORY" \
--run-id "$RUN_ID" \
--last-updated-after "2026-01-01T00:00:00Z" \
--last-updated-before "2027-01-01T00:00:00Z" \
--query "value[].{activity:activityName,status:status,error:error.message}" -o tableThe pipeline may remain InProgress while ADF starts Spark compute. Check again until it reaches a terminal status. You can also inspect the run in Azure Data Factory Studio β Monitor.
az storage blob list \
--account-name "$STORAGE" \
--container-name clean \
--prefix output/ \
--auth-mode login \
-o tableExpected output: clean/output/employees_clean.csv, containing the three employees older than 25 and their 10% salary bonus. Your signed-in Azure identity must have Blob data read permissions for --auth-mode login; the Terraform role assignment grants access to the Data Factory managed identity, not automatically to your user.
terraform destroyStatus: Terraform infrastructure deployment succeeded. Pipeline execution and transformed output have not yet been confirmed. Mapping Data Flow execution incurs Azure compute charges. See Terraform deployment details.
- Azure Data Factory
- Azure Blob Storage
- Azure SQL Database (optional)
- Mapping Data Flow
- Integration Runtime
Example CSV:
id,name,age,salary,department
1,Atul,28,50000,IT
2,Rahul,35,70000,HR
3,Neha,22,30000,IT
4,Ankit,40,90000,Finance-
Create Resource Group
-
Create:
- Storage Account β Upload CSV file
- Azure Data Factory
- Azure SQL Database (optional)
In ADF:
- Blob Storage β connect using access key
- SQL Database β connect using credentials
- Source Dataset β CSV from Blob
- Sink Dataset β SQL Table / Blob
- Select dataset (CSV)
- Enable schema import
Add new column:
salary_with_bonus = salary * 1.1
Condition:
age > 25
- Choose required columns
- Rename columns if needed
- Load into SQL table or Blob
Screenshot captured 1 November 2026 in Azure Data Factory Studio. It shows the deployed visual transformation; pipeline execution is not yet verified.
- Add Data Flow Activity
- Select created Data Flow
- Debug β Publish β Trigger
- Manual Trigger OR Scheduled Trigger
| id | name | age | salary | salary_with_bonus | department |
|---|---|---|---|---|---|
| 1 | Atul | 28 | 50000 | 55000 | IT |
| 2 | Rahul | 35 | 70000 | 77000 | HR |
| 4 | Ankit | 40 | 90000 | 99000 | Finance |
- Visual data transformation
- Runs on Spark cluster (auto-managed)
-
Compute engine for ADF
-
Types:
- Azure IR
- Self-hosted IR
| Feature | Pipeline | Data Flow |
|---|---|---|
| Control Flow | Yes | No |
| Transformation | Limited | Advanced |
| Compute | Orchestration | Spark |
- Data cleaning before ML models
- ETL pipelines for data warehouse
- Log processing
- Batch data transformation
- Use Debug mode for testing
- Partition large datasets
- Use parameterization
- Monitor via ADF Monitor tab
- Use staging for large loads
| Issue | Fix |
|---|---|
| Data Flow slow | Increase compute (DIUs) |
| Schema mismatch | Import schema properly |
| Pipeline fails | Check activity output logs |
| Feature | Data Flow | Copy Activity |
|---|---|---|
| Purpose | Data Transformation (ETL logic) | Data Movement (Lift & Shift) |
| Compute | Spark Cluster (ADF managed) | Integration Runtime |
| Use Case | Complex transformations | Simple copy (Blob β SQL) |
| Performance | Slower (heavy compute) | Faster (direct copy) |
| UI | Visual transformation designer | Simple config |
π Short Answer:
- Copy Activity = Move Data
- Data Flow = Transform Data
π Definition: Integration Runtime is the compute infrastructure used by Azure Data Factory to perform data movement and transformation.
- Azure IR β Cloud-based (default)
- Self-hosted IR β On-premise data access
- Azure-SSIS IR β Run SSIS packages
π Use Case:
- Connect on-prem DB β Cloud
- Execute pipelines & copy activity
π ADF scales automatically using serverless architecture:
- Copy Activity: Scales using parallel threads
- Data Flow: Uses auto-managed Spark clusters
- DIU (Data Integration Units): Controls performance
- Parallel pipelines: Multiple pipelines can run simultaneously
π Key Point: ADF is fully managed β no infra management required
π Definition: Debug mode allows you to test Data Flow transformations without running full pipeline
- Uses temporary Spark cluster
- Preview data at each transformation
- Faster testing & validation
π Important:
- Debug cluster runs β cost is incurred
- Must stop debug after use
- Visual transformation tool in ADF
- Runs on Apache Spark
- No-code / low-code ETL
| Pipeline | Data Flow |
|---|---|
| Orchestration | Transformation |
| Control Flow | Data Processing |
| Lightweight | Compute Heavy |
π Dataset represents:
- Structure of data (schema)
- Location of data (Blob, SQL, etc.)
π Linked Service = Connection to data source Example:
- Blob Storage
- SQL Database
-
Schedule pipeline execution
-
Types:
- Schedule Trigger
- Tumbling Window
- Event-based
π Data Integration Unit (DIU) = Measure of compute power in ADF
- Higher DIU β Better performance
- Used in Copy Activity
- Source: Input data
- Sink: Output destination
- Filter
- Derived Column
- Join
- Aggregate
- Sort
π Always explain like this:
βADF is used for orchestration and ETL. Copy Activity handles data movement, while Data Flow handles transformation using Spark.β
