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)
请帮助我如何避免这个错误
简短的回答 - 您无法使用存储帐户访问密钥来使用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如果您有权访问该存储帐户,您还可以使用直通集群。
小智 5
几个月后,尝试在笔记本中使用以下代码
spark._jsc.hadoopConfiguration().set("fs.azure.account.key.<account name>.dfs.core.windows.net",'<account key>')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47261 次 |
| 最近记录: |