错误:检测到 fs.azure.account.key 的配置值无效

Nab*_*man 13 azure azure-blob-storage azure-databricks

我正在使用 Azure Databricks 使用 ADLS Gen2 在 Azure Blob 存储中创建增量表,但在最后一行收到错误“初始化配置失败检测到 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")
Run Code Online (Sandbox Code Playgroud)

请帮助我如何避免这个错误

Ale*_*Ott 9

简短的回答 - 您无法使用存储帐户访问密钥来使用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")
Run Code Online (Sandbox Code Playgroud)

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

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

  • 从链接的官方文档中我不清楚,只有当您使用“wasbs”时才能使用“存储访问密钥”;你是如何获得这些信息的?我知道wasbs不建议再使用了。 (4认同)
  • 我假设上面是“client.id”。需要在azure中注册应用程序吗? (2认同)
  • 我认为链接文档的问题在于,它缺乏每种类型的身份验证的示例,因为存在不起作用的方法和协议的组合,但这在文档中没有明确说明,例如“只有当您“正在使用 wasbs”,不在该页面中。 (2认同)

小智 5

几个月后,尝试在笔记本中使用以下代码

spark._jsc.hadoopConfiguration().set("fs.azure.account.key.<account name>.dfs.core.windows.net",'<account key>')
Run Code Online (Sandbox Code Playgroud)