0

I was trying to setup using the scopes and I am having a few issues. Any help would be appreciated.

I ran the below commands in Databricks CLI

databricks secrets create-scope --scope dnb-dlg2-dbrcks-scp-stg
databricks secrets put --scope dnb-dlg2-dbrcks-scp-stg --key SPID --string-value "XXXXXXXXXXXXXXXXXX"
databricks secrets put --scope dnb-dlg2-dbrcks-scp-stg --key SPKey --string-value "XXXXXXXXXXXXXXX”
databricks secrets put --scope dnb-dlg2-dbrcks-scp-stg --key DirectoryID --string-value "XXXXXXXXXX"

Successfully created the scope. Then I tried to run the below in my notebook

#Gather Relevant Keys from our scope

ServicePrincipalId=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPID")
ServicePrincipalKey=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPKey")
DirectoryID=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="DirectoryID")

#Combine DirectoryID into full string
Directory="https://login.microsoftonline.com/{}/oauth2/token".format(DirectoryID)

#Create configurations for our connections
configs = {"fs.azure.account.auth.type": "OAuth",
           "fs.azure.account.oauth.provider.type": "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider",
           "fs.azure.account.oauth2.client.id" : ServicePrincipalId,
           "fs.azure.account.oauth2.client.secret":  ServicePrincipalKey,
           "fs.azure.account.oauth2.client.endpoint": Directory}
# "fs.azure.account.oauth2.client.secret" -> dbutils.secrets.get("dnb-dbrk-scrt-scp-stg", key = "dnb-data-bricks-kv-stg"),

# Mount the Data Lake onto DBFS at the /mnt/ location

dbutils.fs.mount(
  source = "abfss://datastore@dbstgstoraccgen2.dfs.core.windows.net/",
  mount_point = "/mnt/datastore5",
  extra_configs = configs)

I get an error at this point .Please refer to the image below

Error

ERROR DETAILS

    AttributeError: 
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<command-4345234368633882> in <module>
----> 1 dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPID")

/local_disk0/tmp/1575916741583-0/dbutils.py in __getattr__(self, item)
    482             return self.credentials
    483 
--> 484         raise AttributeError
    485 
    486     def __repr__(self):

AttributeError: 
Peter Pan
  • 23,476
  • 4
  • 25
  • 43
kranny
  • 17
  • 5

1 Answers1

0

Small typo mistake in your code: "secret" should be "secrets".

enter image description here

Error:

ServicePrincipalId=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPID")
ServicePrincipalKey=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPKey")
DirectoryID=dbutils.secret.get(scope="dnb-dlg2-dbrcks-scp-stg",key="DirectoryID")

Replace "secret.get" with "secrets.get"

ServicePrincipalId=dbutils.secrets.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPID")
ServicePrincipalKey=dbutils.secrets.get(scope="dnb-dlg2-dbrcks-scp-stg",key="SPKey")
DirectoryID=dbutils.secrets.get(scope="dnb-dlg2-dbrcks-scp-stg",key="DirectoryID")

enter image description here

Hope this helps. Do let us know if you any further queries.


Do click on "Mark as Answer" and Upvote on the post that helps you, this can be beneficial to other community members.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
  • Hi @kranny, Just checking in to see if the above answer helped. 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. – CHEEKATLAPRADEEP Dec 16 '19 at 08:30