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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
A_monged
New Contributor III

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
Contributor III

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
NandanHegde
Valued Contributor II

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
spencer_sa
Contributor III

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.

Helpful resources

Announcements
Users online (27)