我正在尝试使用 Key Vault 支持的机密范围将 Azure Blob 存储容器装载到 Databricks 工作簿。
设置:
- 创建了 Key Vault
- 在 Key Vault 中创建了一个秘密
- 创建了一个 Databricks 秘密范围
- 这是众所周知的。
- 运行
dbutils.secrets.get(scope = dbrick_secret_scope, key = dbrick_secret_name)
结果没有错误 - 在 Databricks 中查看机密会导致
[REDACTED]
- 运行
Databricks 中的单元格:
%python
dbrick_secret_scope = "dbricks_kv_dev"
dbrick_secret_name = "scrt-account-key"
storage_account_key = dbutils.secrets.get(scope = dbrick_secret_scope, key = dbrick_secret_name)
storage_container = 'abc-test'
storage_account = 'stgdev'
dbutils.fs.mount(
source = f'abfss://{storage_container}@{storage_account}.dfs.core.windows.net/',
mount_point = f'/mnt/{storage_account}',
extra_configs = {f'fs.azure.accountkey.{storage_account}.dfs.core.windows.net:{storage_account_key}'}
)
结果:
- 错误:
AttributeError: 'set' object has no attribute 'keys'
以红色突出显示的mount_point
行。dbutils.fs.mount()
- 完整错误:
AttributeError Traceback (most recent call last)
<command-3166320686381550> in <module>
9 source = f'abfss://{storage_container}@{storage_account}.dfs.core.windows.net/',
10 mount_point = f'/mnt/{storage_account}',
---> 11 extra_configs = {f'fs.azure.accountkey.{storage_account}.dfs.core.windows.net:{storage_account_key}'}
12 )
/local_disk0/tmp/1625601199293-0/dbutils.py in f_with_exception_handling(*args, **kwargs)
298 def f_with_exception_handling(*args, **kwargs):
299 try:
--> 300 return f(*args, **kwargs)
301 except Py4JJavaError as e:
302 class ExecutionError(Exception):
/local_disk0/tmp/1625601199293-0/dbutils.py in mount(self, source, mount_point, encryption_type, owner, extra_configs)
389 self.check_types([(owner, string_types)])
390 java_extra_configs = \
--> 391 MapConverter().convert(extra_configs, self.sc._jvm._gateway_client)
392 return self.print_return(self.dbcore.mount(source, mount_point,
393 encryption_type, owner,
/databricks/spark/python/lib/py4j-0.10.9-src.zip/py4j/java_collections.py in convert(self, object, gateway_client)
520 HashMap = JavaClass("java.util.HashMap", gateway_client)
521 java_map = HashMap()
--> 522 for key in object.keys():
523 java_map[key] = object[key]
524 return java_map
AttributeError: 'set' object has no attribute 'keys'
似乎与extra_configs
参数有关,但我不确定是什么。谁能看到我错过了什么?