cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to programatically retrieve a workspace name ?

AmarK
Databricks Employee
Databricks Employee

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?

2 REPLIES 2

Navya_R
Databricks Employee
Databricks Employee

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
Databricks Employee
Databricks Employee

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.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group