If you’re working with end-to-end data solutions in Microsoft Fabric, managing task dependencies is crucial. This post explores how DAG orchestration in Microsoft Fabric helps automate the execution of dependent notebooks using SQL and JSON. Whether you’re building pipelines or orchestrating data flows, this method will streamline your process and reduce manual effort.
What Is DAG Orchestration in Microsoft Fabric?
A DAG (Directed Acyclic Graph) is a foundational structure in data engineering used to manage task dependencies. It ensures that tasks (or notebooks, in this case) execute in a specific sequence without looping back.
Microsoft Fabric supports DAG execution through the notebookutils.notebook.runMultiple() function. While you can simply pass a list of notebooks to run in parallel, a DAG allows you to define an entire execution flow complete with parent-child relationships between notebooks.
Simple Parallel Execution vs. Structured DAG
You can run notebooks in parallel with a basic command:
notebookutils.notebook.runMultiple(["Notebook1", "Notebook2"])
This works well for unrelated tasks. However, when Notebook B depends on Notebook A, you need to define a structured execution plan. That’s where DAG comes in.
Creating a DAG with JSON
Microsoft Fabric allows you to define notebook dependencies using a JSON document structured like this:
{
"activities": [
{
"name": "NotebookA",
"type": "Notebook",
"dependsOn": []
},
{
"name": "NotebookB",
"type": "Notebook",
"dependsOn": ["NotebookA"]
}
]
}
You then trigger the entire workflow with:
notebookutils.notebook.runMultiple(dagJson)
This method ensures each notebook runs in the correct order, based on the relationships defined in the JSON.
Automating DAG JSON Creation with SQL Graph
Manually building this JSON each time is tedious and error-prone. Fortunately, Microsoft Fabric allows us to use SQL graph tables to automate the creation of this structure.
Here’s how:
Step 1: Create a Fabric SQL Database
Start by setting up a SQL database in Microsoft Fabric.
Step 2: Define Graph Tables
- Parameters table (nodes): Each row represents a notebook and its attributes.
- DependsOn table (edges): Specifies which notebook depends on which.
Step 3: Use Stored Procedures
Create stored procedures to insert notebook metadata and define dependencies. This provides a repeatable and structured way to build the orchestration logic.
Step 4: Generate JSON with FOR JSON PATH
Use a SQL query to format the notebook graph into the exact JSON structure needed by Fabric’s runMultiple() function. This step automates the previously manual process of writing DAG documents.
Real-World Use Case and Execution
Once the DAG JSON is generated, paste it into your orchestration notebook and run it. Fabric intelligently queues and executes notebooks according to the defined dependencies.
The benefits are clear:
- Reduced manual configuration
- Improved reliability
- Scalable workflows
Even better, this approach can be extended to handle more advanced orchestration patterns as your solutions grow.
Looking Ahead
The current method still requires copying the JSON into your notebook manually but automation enthusiasts will be pleased to know that a follow-up technique is on the way to completely automate that step as well. Stay tuned.
Learn More with Expert Training
If you’re interested in mastering Microsoft Fabric, Power BI, and DAX workflows, check out Data Bear’s Power BI Training. Their sessions cover foundational concepts and advanced techniques, giving you the skills to build smarter, more automated solutions.


