Parent-Child Design Pattern in Azure Data Factory

The Parent-Child design pattern in Azure Data Factory (ADF) is a powerful approach to dynamically orchestrating data pipelines. It simplifies handling scenarios where multiple tasks need to process data dynamically based on input. This blog post outlines how to design a Parent pipeline that orchestrates a Child pipeline to create files dynamically in an Azure Data Lake Storage Gen2 container. We’ll use an example involving schema and table names dynamically fetched from a database.
Use Case
We want to generate files in Azure Data Lake Gen2 with filenames that are dynamically created using a combination of the database schema and table names. This design leverages the Parent pipeline for control and the Child pipeline for execution.
Parent Pipeline
The Parent pipeline handles:
Fetching Table Metadata:
A
Lookupactivity runs a query to fetch table schema and table names dynamically from the source database. Here's the query used:SELECT table_schema, table_name FROM information_schema.tables WHERE table_name LIKE 'Customer%'This query returns a list of tables whose names start with "Customer" from the database.
Iterating Over the Results:
- A
ForEachactivity iterates through the array returned by theLookupactivity. Each iteration corresponds to a row in the table list (one table schema and table name pair).
- A
Calling the Child Pipeline:
- Inside the
ForEachactivity, anExecute Pipelineactivity is used to invoke the Child pipeline. The schema and table name from the current iteration are passed as parameters to the Child pipeline.
- Inside the
Child Pipeline
The Child pipeline is responsible for:
Copying Data to ADLS Gen2:
A
Copy Dataactivity is used to transfer data from the source database to Azure Data Lake Storage Gen2.The destination filename is dynamically defined based on the parameters passed from the Parent pipeline (
schemaandtable_name). For instance, if the table is in thesalesschema and is namedCustomerInfo, the output file would be namedsales.CustomerInfo.This is achieved using the Sink Dataset in the
Copy Dataactivity. The filename is configured using the following expression:@concat(pipeline().parameters.schema, '.', pipeline().parameters.table_name)This expression concatenates the schema and table name with a dot separator.
Steps to Create the Pipelines
1. Create the Parent Pipeline
Add a
Lookupactivity:- Configure it with the query to fetch
schemaandtable_namefrom the source database.
- Configure it with the query to fetch
Add a
ForEachactivity:Set the
Itemsproperty to the output of theLookupactivity.Inside the
ForEachactivity, add anExecute Pipelineactivity and pass theschemaandtable_namedynamically.
2. Create the Child Pipeline
Add parameters to the pipeline:
schemaandtable_name.
Add a
Copy Dataactivity:Configure the Source dataset with the dynamic table (
schema.table_name) if needed.Configure the Sink dataset:
- Set the
filenameproperty to use the expression@concat(pipeline().parameters.schema, '.', pipeline().parameters.table_name).
- Set the

Benefits of this Design
Reusability: The Child pipeline can be reused for different tasks since it is driven by parameters.
Scalability: The Parent pipeline handles multiple table schemas and table names dynamically without manual configuration.
Flexibility: You can extend this design for additional transformations or use cases
Conclusion
The Parent-Child design pattern in Azure Data Factory is ideal for dynamic and scalable data orchestration. In this example, you’ve learned how to:
Fetch dynamic metadata from a database.
Use
ForEachto iterate through the metadata.Invoke a parameterized Child pipeline to handle dynamic data movement and transformations.
This design can be a robust foundation for automating data workflows in Azure.




