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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
Fabric July 2025 Monthly Update Carousel

Fabric Monthly Update - July 2025

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

July 2025 community update carousel

Fabric Community Update - July 2025

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