cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Is there a way to programatically retrieve a workspace name ?

AmarK
New Contributor III
New Contributor III

Is there a spark command in databricks that will tell me what databricks workspace I am using? Iโ€™d like to parameterise my code so that I can update delta lake file paths automatically depending on the workspace (i.e. it picks up the dev workspace name when in dev and will pick up the prod workspace name in prod). Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @Amar Kadamalakunteโ€‹ , This link will probably give you the perfect solution. Please let me know if that helps you.

View solution in original post

3 REPLIES 3

Navya_R
New Contributor III
New Contributor III

You may run the below in a notebook within the workspace:

dbutils.entry_point.getDbutils().notebook().getContext().toJson()

The output contains: 

browserHostName - is the workspace name

orgId - is the workspaceID

AmarK
New Contributor III
New Contributor III

Screenshot 2022-02-04 at 08.54.25Thanks Navya! But this doesn't work for me on a High Concurrency cluster. It seems that toJson() isn't whitelisted.

Kaniz
Community Manager
Community Manager

Hi @Amar Kadamalakunteโ€‹ , This link will probably give you the perfect solution. Please let me know if that helps you.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.