Search code examples
databricksazure-databrickssecret-keyapache-commons-dbutils

Unable to use SecretKey in Databricks


I am trying to use the created secret key on databricks using dbutils.secrets.get(scope="jdbc", key="username") command; but I get an error saying 'Secret does not exist with scope: jdbc and key: username'.

I am creating the secret key using CLI -

databricks secrets put --scope jdbc --key username

I can even see the created keys on CLI using the command

databricks secrets list --scope jdbc

Any help is very much appreciated.

Thank you!!


Solution

  • Note: You will receive this error message because "Once you have created a Databricks-backed scope, you can secrets".

    Steps to create a Databricks-backed secret scope:

    Create a scope using databricks cli:

    Cmdlet to create a scope databricks secrets create-scope --scope <scope-name>

    Once you have created a Databricks-backed secret scope, you can add secrets.

    Cmdlet to create a secret key: databricks secrets put --scope <scope-name> --key <keyname>

    You can check-out the complete steps to create a Databricks-backed secret scope creation.

    enter image description here

    Hope this helps.


    If this answers your query, do click “Mark as Answer” and "Up-Vote" for the same. And, if you have any further query do let us know.