AZURE DATABRICKS - How To Modify existing Secret Scope?




I have been working on Azure Databricks (DBx) for 3/4 weeks and there are loads of things that I have been fortunate enough to learn. I always wanted to explore or find out more about Azure DBx and just grateful enough to be given a chance to use it in a real project. 

Let's get to the technicalities then. 

The other day I stumbled upon this error while running a DBx notebook 

User username@domain.com does not have READ permission on scope xxx_yyy to perform this action.

So the problem statement was to find out the details of scope xxx_yyy. 

I assume if you are reading this article you will have an idea of what secret scopes are in context to Azure Databricks. 

You can read more on it here Secret Scopes - Azure DBx

Now I will list out the steps to create and manage secret scopes. Creating can be done through UI on azure portal but for managing the scope the process is little different. Please go through the following steps

CREATE

1. For creating scopes using key vault open the following web page
<yourdatabricksurl>#secrets/createScope

2. Refer to the step detailed in this article

MANAGE/MODIFY

For managing scopes, we'll have to use CLIs. It cant be done using portal

1. Make sure python is installed and the path is copied to be used in subsequent step. 
The path will look like this -      
C:\Users\Arnold Commando\AppData\Local\Programs\Python\Python39

 

2. Open command prompt and make sure you are under this path
cd C:\Users\Arnold Commando\AppData\Local\Programs\Python\Python39

3. Navigate to https://bootstrap.pypa.io/get-pip.py and copy the code in notepad file. Give it a name get-pip.py and make sure it is saved under  
C:\Users\Arnold Commando\AppData\Local\Programs\Python\Python39

4. run this command
python get-pip.py

5. For steps 3 and 4, you can refer to this article

6. Install data bricks CLI by using below command
pip install databricks-cli

7. Downgrade the cli version by using below command
python -m pip install --upgrade pip setuptools wheel databricks-cli==0.11.0

8. run the following command
databricks configure --token
Make sure you are inside scripts folder
cd C:\Users\Arnold Commando\AppData\Local\Programs\Python\Python39\Scripts

9. The Interface will ask for "Databricks Host (should begin with https://):"
[What I entered]
https://eastus.azuredatabricks.net

10. Interface will now ask for 
"Token:"
Generate token from databricks workspace and paste here.

11. Run the following command to see if the authentication was succesfully 
databricks fs ls

12. It should return, something like
ml
mnt
tmp

13. Run the following command to check the scope details
databricks secrets list-acls --xxx_yyy <secret scope name>

14. Modify the permissions by using below command
databricks secrets put-acl --scope <secret scope name>  --principal <username@domain.com> --permission READ


So here it is. Hope this was helpful.  

Comments

Popular posts from this blog

Issues Integrating Azure Data Factory with GITHUB | IN spite of admin rights on repository

SQL QUERY NIGHTMARE

Handling decimal and non numeric types using Case statement