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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

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
FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

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.

March Fabric Update Carousel

Fabric Monthly Update - March 2026

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