首页 > 解决方案 > 错误:检测到 fs.azure.account.key 的配置值无效

问题描述

我正在使用 Azure Databricks 使用 ADLS Gen2 在 Azure Blob 存储中创建一个增量表,但我在最后一行收到错误“无法初始化 configurationInvalid configuration value detected for fs.azure.account.key”

%scala
spark.conf.set(
    "fs.azure.account.oauth2.client.secret",
    "<storage-account-access-key>")
friends = spark.read.csv('myfile/fakefriends-header.csv',
   inferSchema = True, header = True)
friends.write.format("delta").mode('overwrite')\
   .save("abfss://tempfile@tempaccount.dfs.core.windows.net/myfile/friends_new")

请帮助我如何避免此错误

标签: azureazure-blob-storageazure-databricks

解决方案


简短的回答 - 您不能使用存储帐户访问密钥来使用abfss协议访问数据。如果你想使用,你需要提供更多的配置选项abfss——这一切都在文档中描述。

spark.conf.set(
  "fs.azure.account.auth.type.<storage-account-name>.dfs.core.windows.net", 
  "OAuth")
spark.conf.set(
  "fs.azure.account.oauth.provider.type.<storage-account-name>.dfs.core.windows.net", 
  "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set(
  "fs.azure.account.oauth2.client.id.<storage-account-name>.dfs.core.windows.net", 
  "<application-id>")
spark.conf.set(
  "fs.azure.account.oauth2.client.secret.<storage-account-name>.dfs.core.windows.net", 
  dbutils.secrets.get(scope="<scope-name>",key="<service-credential-key-name>"))
spark.conf.set(
  "fs.azure.account.oauth2.client.endpoint.<storage-account-name>.dfs.core.windows.net", 
  "https://login.microsoftonline.com/<directory-id>/oauth2/token")

存储访问密钥只能在使用时使用wasbs,但不建议与 ADLSGen2 一起使用。

PS如果您有权访问该存储帐户,您也可以使用直通集群。


推荐阅读