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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Nytar
Regular Visitor

How to List and Execute Notebooks in Microsoft Fabric?

Hi,

I'm using Microsoft Fabric and need help managing notebooks in my workspace. Specifically:

  1. How to list notebooks stored in various directories?
  2. How to execute these notebooks from a central notebook?

My current function lists objects in lakehouses:

 

# List all objects in the root folder
root = mssparkutils.fs.ls("/")

for item in root:
    print(item.name)  # Print the name of the object

    # List all objects in the subfolder
    subitems = mssparkutils.fs.ls(item.path)
    for subitem in subitems:
        print("  " + subitem.name)  # Print the name of the subitem

        # List all objects in the subsubfolder
        subsubitems = mssparkutils.fs.ls(subitem.path)
        for subsubitem in subsubitems:
            print("    " + subsubitem.name)  # Print the name of the subsubitem

 

However, this code doesn’t list my notebooks. Any guidance would be appreciated!

Thank you!

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Nytar ,

 

Thanks @frithjof_v for your reply.

 

Please execute the following code in notebook:

import requests

workspaceID = 'your_workspace_id'
api_url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspaceID}/notebooks'
headers = {
   "Authorization": "Bearer your_token",
   "Content-Type": "application/json"
}

res = requests.get(api_url,headers=headers)
note = res.json().get("value",[])

for note in note:
    if note['type'] == 'Notebook':
        print(note['displayName'])

 

Replace workspaceid and your_token with your own.

 

The result of the execution is shown below, which lists all the notebooks in my workspace.

vhuijieymsft_0-1721714684725.png

 

You can click on this official document for more information about it:

Items - List Notebooks - REST API (Notebook) | Microsoft Learn

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Nytar ,

 

Thanks @frithjof_v for your reply.

 

Please execute the following code in notebook:

import requests

workspaceID = 'your_workspace_id'
api_url = f'https://api.fabric.microsoft.com/v1/workspaces/{workspaceID}/notebooks'
headers = {
   "Authorization": "Bearer your_token",
   "Content-Type": "application/json"
}

res = requests.get(api_url,headers=headers)
note = res.json().get("value",[])

for note in note:
    if note['type'] == 'Notebook':
        print(note['displayName'])

 

Replace workspaceid and your_token with your own.

 

The result of the execution is shown below, which lists all the notebooks in my workspace.

vhuijieymsft_0-1721714684725.png

 

You can click on this official document for more information about it:

Items - List Notebooks - REST API (Notebook) | Microsoft Learn

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

frithjof_v
Super User
Super User

1. Perhaps this will do the job, it also seems to list the notebooks in the workspace: https://fabric.guru/one-line-code-to-get-a-list-of-items-from-all-the-fabricpremium-workspaces

 

2. I think you can use some of the functions found here: 

 

https://learn.microsoft.com/en-us/fabric/data-engineering/microsoft-spark-utilities#notebook-utiliti...

 

 

Edit: this blog shows how to achieve both 1. and 2.:

 

https://fabric.guru/using-runmultiple-to-orchastrate-notebook-execution-in-microsoft-fabric

 

To list all notebooks in the workspace:

 

import sempy.fabric as fabric

notebooks = fabric.list_items().query("Type == 'Notebook'")

notebooks

Helpful resources

Announcements
September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors