我试图使用示波器进行设置,但遇到了一些问题。任何帮助,将不胜感激。
我在 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"
成功创建范围。然后我尝试在我的笔记本中运行以下内容
#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)
此时我收到错误消息。请参考下图
错误详情
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: