【发布时间】:2021-11-10 22:56:09
【问题描述】:
我正在使用 Azure Synapse Analytics 笔记本连接到 RESTful api,并将 json 文件写入 Azure Data Lake Storage Gen 2。
pyspark 代码:
import requests
response = requests.get('https://api.web.com/v1/data.json')
data = response.json()
from pyspark.sql import *
df = spark.read.json(sc.parallelize([data]))
from pyspark.sql.types import *
account_name = "name of account"
container_name = "name of container"
relative_path = "name of file path" #abfss://<container_name>@<storage_account_name>.dfs.core.windows.net/<path>
adls_path = 'abfss://%s@%s.dfs.core.windows.net/%s' % (container_name, account_name, relative_path)
spark.conf.set('fs.%s@%s.dfs.core.windows.net/%s' % (container_name, account_name), "account_key") #not sure I'm doing the configuration right
df.write.mode("overwrite").json(adls_path)
错误:
Py4JJavaError : An error occurred while calling o536.json.
: Operation failed: "This request is not authorized to perform this operation.", 403, HEAD, https://storageaccount.dfs.core.windows.net/container/?upn=false&action=getAccessControl&timeout=90
【问题讨论】:
-
您有 Storage Blob Data Contributor 权限吗?您的问题与微软论坛上的this讨论有关
-
嗨@Kafels,我确实有存储 Blob 数据贡献者权限,但仍然遇到此错误。
标签: apache-spark pyspark azure-synapse