cancel
Showing results for 
Search instead for 
Did you mean: 
Community Discussions
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a python package that uses dbutils.secrets

samarth_solanki
New Contributor II

Hello Databricks,
I wanted to create python package which has a python script which has a class , this class is where we give scope and key and we het the secret. This package will be used inside a databricks notebook 
I want to use dbutils.secret for this
Q1. I have used dbutils in my code , but when i import this package in notebook and run it it shows dbutils not defined, is it not possible it takes dbutils on itself when running this package in notebook.
Q2. Then I also added "from databricks.sdk.runtime import dbutils" but this throws error saying "cannot configure default auth"
I want to create this python package locally and run it in databricks notebook where it can use dbutils , what can i do?

2 REPLIES 2

BR_DatabricksAI
Contributor

Hello samarth_solanki, 

Any specific reason for using the scope & key in class, however in data bricks and as a best practice we can create the two types of Databricks Secret Scopes:

 Azure Key Vault-Backed Scope :

Users can create a Secret Scope backed by the Azure Key Vault. It allows users to leverage all the Secrets in the corresponding Key Vault instance from a particular Secret Scope. 

Databricks-Backed Scope

In this method, the Secret Scopes are managed with an internally encrypted database owned by the Databricks platform. Users can create a Databricks-backed Secret Scope using the Databricks CLI .

This option would be viable for you in case if don't want to leverage the azure key vault option. 

Thanks

 

 

 

mfall-shift
New Contributor II

@samarth_solanki wrote:

Hello Databricks,
I wanted to create python package which has a python script which has a class , this class is where we give scope and key and we het the secret. This package will be used inside a databricks notebook 
I want to use dbutils.secret for this
Q1. I have used dbutils in my code , but when i import this package in notebook and run it it shows dbutils not defined, is it not possible it takes dbutils on itself when running this package in notebook.
Q2. Then I also added "from databricks.sdk.runtime import dbutils" but this throws error saying "cannot configure default auth"
I want to create this python package locally and run it in databricks notebook where it can use dbutils , what can i do?


Hello, I have exactly the same issue (in my case I want to use dbutils.fs.ls). Did you find a solution?

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.