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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Super User
Super User

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
Super User
Super User

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
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.