Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Yazdan
New Contributor III

Using Multiple %run Commands in Microsoft Fabric Notebooks

Tip: Using Multiple %run Commands in Microsoft Fabric Notebooks

 

I recently discovered something useful when working with multiple notebooks in Microsoft Fabric using the %run magic command.

 

When you try to load more than one notebook in the same cell like this:

 

%run NB_Slv_Logger
%run NB_Slv_Email_Configuration

 

You’ll get an error saying that no other code or commands can be combined with %run, and that no code can appear above or below the magic %run command in the same cell.

Even separating them with an empty line doesn’t work:

 

%run NB_Slv_Logger
 
%run NB_Slv_Email_Configuration

 

Result: Error – Fabric doesn’t allow multiple %run statements or any extra code in the same cell.

 

Solution:
Place each %run command in its own separate code cell.
Example:

 

# Cell 1
%run NB_Slv_Logger

 

 
# Cell 2
%run NB_Slv_Email_Configuration

 

After running both cells, you’ll have access to all functions, classes, and variables from both notebooks within your current notebook.


Key takeaway

Each %run must be executed independently in its own cell — no other code should exist above or below it. Once both are run, their code is fully imported and available.

 

Hope this helps anyone integrating multiple shared notebooks (e.g., for logging, configuration, or utilities) in Fabric!

3 REPLIES 3
BhaveshPatel
Honored Contributor

 Hi @Yazdan 

 

%run command is used for Global Parameters in Microsoft Fabric or Equivalent to Databricks Delta Lake.

 

BhaveshPatel_0-1760083738308.png

 

 

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.
v-saisrao-msft
Honored Contributor II

Hi @Yazdan,

Thank you @BhaveshPatel, for your insights.

Below is the link for your reference regarding the issue:

Orchestrate notebooks and modularize code in notebooks - Azure Databricks | Microsoft Learn

The link explains how to modularize notebooks using %run and orchestrate them using dbutils.notebook.run()

 

Thank you.

v-saisrao-msft
Honored Contributor II

Hi @Yazdan,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further.

 

Thank you.

Helpful resources

Announcements
Users online (11,086)