How to get Databricks WorkspaceID from REST API using PowerShell?

Getting information about ID of the Azure Databricks workspace is not so obvious.

There is no information about it in the API specification: https://docs.databricks.com/api/latest/workspace.html

That’s probably because this property is not related to the content of the workspace 🙂 That’s right! Raw JSON responses are intended to deliver different set of content in a different scope. On the other hand, I personally think that this should be in official API! Nevertheless…

 

So what contains workspace details? Turns out the answer is simple: HEADER of your any request response 🙂

 

Just execute your request, it could be any kind, like folder listing.

Then get the content of the headers in your REST response. Look for the X-Databricks-Org-Id key. It will simply represent your Workspace ID that you’re looking for 🙂

 

Try it with this example based on a command that lists folders in a root path:

 

Output:

 

Leave a Reply