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:ย 

Databricks CLI configure (using AAD-TOKEN) in the Databricks notebook `%sh` mode

juned
New Contributor III

Hello everyone, I am trying to setup Databricks CLI by referring to the Databricks CLI documentation. When I setup using the Personal Access Token, it works fine and I am able to access the workspace and fetch the results from the same workspace in Databricks notebook %sh mode.

But when I try to configure using AAD-TOKEN, it shows me the below message -

image 

I have the AAD TOKEN value and I tried to add it to the env variable using the below command -

%sh

export DATABRICKS_AAD_TOKEN=<token_value>

But for some reason it doesn't show up in the env variable file.

Am I missing here something?

The Databricks documentation also doesn't provide much information on how to configure Databricks CLI using AAD-TOKEN. Is this correct way?

1 ACCEPTED SOLUTION

Accepted Solutions

Trinomial
New Contributor III

Hi @Juned Malaโ€‹,

I was having exactly the same problem using Azure Databricks. I agree the documentation on setting up Databricks CLI is so inadequate, and others agree.

I'm using Azure Databricks on a Windows machine, with the Anaconda build for Python (authenticating using Anaconda PowerShell Prompt).

I think the problem for me first arose when running

databricks configure --aad-token

before I had set the Environment variable.

We need to make sure the Environment Variable is set before running the above command. I think you have done this part, but for the benefit of other readers I'll post it here. To set the Environment Variable, go to Control Panel, search for Environment Variables and click 'New' to enter a new (User) environment variable:

Variable name = DATABRICKS_AAD_TOKEN

Variable value= <your AD token>

Close down PowerShell and open it again. Run the command

databricks configure --aad-token

again. Enter your Databricks host URL when prompted, e.g.

https://adb-<workspace-id>.<random-number>.azuredatabricks.net

This should update the .databrickscfg file under your User directory (C:\Users\<user.id>) to include the Host and the AAD Token that you entered as the new Environment Variable.

Then try running

databricks workspace list /Users

and hopefully the Users in your Workspace Path will be listed, if authentication has succeeded.

View solution in original post

4 REPLIES 4

Debayan
Databricks Employee
Databricks Employee

juned
New Contributor III

Yes, I already tried all the steps in this document for the AAD token configuration but it shows the message in the screenshot above. I tried to add DATABRICKS_AAD_TOKEN to env but not working.

Trinomial
New Contributor III

Hi @Juned Malaโ€‹,

I was having exactly the same problem using Azure Databricks. I agree the documentation on setting up Databricks CLI is so inadequate, and others agree.

I'm using Azure Databricks on a Windows machine, with the Anaconda build for Python (authenticating using Anaconda PowerShell Prompt).

I think the problem for me first arose when running

databricks configure --aad-token

before I had set the Environment variable.

We need to make sure the Environment Variable is set before running the above command. I think you have done this part, but for the benefit of other readers I'll post it here. To set the Environment Variable, go to Control Panel, search for Environment Variables and click 'New' to enter a new (User) environment variable:

Variable name = DATABRICKS_AAD_TOKEN

Variable value= <your AD token>

Close down PowerShell and open it again. Run the command

databricks configure --aad-token

again. Enter your Databricks host URL when prompted, e.g.

https://adb-<workspace-id>.<random-number>.azuredatabricks.net

This should update the .databrickscfg file under your User directory (C:\Users\<user.id>) to include the Host and the AAD Token that you entered as the new Environment Variable.

Then try running

databricks workspace list /Users

and hopefully the Users in your Workspace Path will be listed, if authentication has succeeded.

Anonymous
Not applicable

Hi @Juned Malaโ€‹ 

Hope all is well! Just wanted to check in if you were able to resolve your issue and would you be happy to share the solution or mark an answer as best? Else please let us know if you need more help. 

We'd love to hear from you.

Thanks!

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