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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
A_monged
Frequent Visitor

How to retrieve current notebook name

How to retrieve the current notebook name 

I don't want to hardcode it

1 ACCEPTED SOLUTION
spencer_sa
Impactful Individual
Impactful Individual

You should be able to get a stack of useful info from the notebookutils.runtime.context structure.

For example, executing the below:

print(notebookutils.runtime.context['currentNotebookName'])

returns to following imaginatively titled name;

MyAwesomeNotebook

 
The full list of things you can return is;

'currentNotebookName', 'currentWorkspaceName', 'defaultLakehouseName', 'defaultLakehouseId', 'parentRunId', 'isReferenceRun', 'defaultLakehouseWorkspaceId', 'hcReplId', 'activityId', 'defaultLakehouseWorkspaceName', 'currentWorkspaceId', 'referenceTreePath', 'clusterId', 'poolName', 'environmentId', 'currentNotebookId', 'userId', 'environmentWorkspaceId', 'userName', 'currentRunId', 'isForPipeline', 'rootRunId'

 

If this helps at all, please consider Accepting as a Solution so that other users may find it more easily.

View solution in original post

2 REPLIES 2
spencer_sa
Impactful Individual
Impactful Individual

You should be able to get a stack of useful info from the notebookutils.runtime.context structure.

For example, executing the below:

print(notebookutils.runtime.context['currentNotebookName'])

returns to following imaginatively titled name;

MyAwesomeNotebook

 
The full list of things you can return is;

'currentNotebookName', 'currentWorkspaceName', 'defaultLakehouseName', 'defaultLakehouseId', 'parentRunId', 'isReferenceRun', 'defaultLakehouseWorkspaceId', 'hcReplId', 'activityId', 'defaultLakehouseWorkspaceName', 'currentWorkspaceId', 'referenceTreePath', 'clusterId', 'poolName', 'environmentId', 'currentNotebookId', 'userId', 'environmentWorkspaceId', 'userName', 'currentRunId', 'isForPipeline', 'rootRunId'

 

If this helps at all, please consider Accepting as a Solution so that other users may find it more easily.

NandanHegde
Super User
Super User

Based on my understanding, Microsoft Fabric doesn’t provide an automatic way to get the current notebook name from within the notebook interface.

You need to either manually pass the notebook id or hardcode the notebook name




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Helpful resources

Announcements
April Fabric Update Carousel

Fabric Monthly Update - April 2026

Check out the April 2026 Fabric update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.