我试图使用示波器进行设置,但遇到了一些问题。任何帮助将不胜感激。
我在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:
答案 0 :(得分:0)
您的代码中的拼写错误小:“ 秘密”应为“ 秘密”。
错误:
TypeConverter
将“ secret.get ”替换为“ secrets.get ”
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")
希望这会有所帮助。如果您还有其他疑问,请告诉我们。
请在有助于您的帖子上单击“标记为答案”,然后点击“赞”,这可能会对其他社区成员有所帮助。