无法使用匿名凭据访问帐户myblobcontainer中的容器$ root,并且在配置中找不到用于它们的凭据

时间:2018-10-15 00:56:48

标签: azure azure-storage-blobs databricks

我正在尝试连接到DataBricks笔记本中的Azure blob文件。

spark.conf.set(
  "fs.azure.sas.myblobcontainer.mystorageaccount.blob.core.windows.net",
  "mysastoken")

df = spark.read.format(file_type).option("inferSchema", "true").load(file_location)

我得到了错误:

Unable to access container $root in account badrulsblobcontainer using anonymous credentials, and no credentials found for them  in the configuration.

我已经在Azure中为我的容器创建了一个SAS密钥

2 个答案:

答案 0 :(得分:0)

根据错误信息,您无权获取容器数据。实际上,如果您配置了具有权限的容器(仅对blob进行匿名读取访问),则只能通过匿名请求读取容器内的blob,但是容器数据不可用。有关更多详细信息,请参阅document

此外,我找到了一个解决天蓝色查询的好渠道:https://support.microsoft.com/en-us/help/3174960/dev-chat-for-office365-azure,所有天蓝色或O365的查询对象似乎总是可以回答的,您可以尝试一下。

答案 1 :(得分:0)

根据您的错误消息,我认为您的SAS令牌不起作用。建议您将创建SAS令牌与Microsoft Azure Storage Explorer一起使用。

enter image description here

enter image description here

enter image description here

此外,有关如何连接Azure blob的信息,请参阅document

spark.conf.set(
  "fs.azure.sas.<your-container-name>.<your-storage-account-name>.blob.core.windows.net",
  "<the query string you copy>") 

dbutils.fs.ls("wasbs://<your-container-name>@<your-storage-account-name>.blob.core.windows.net/<your-directory-name>")

结果: enter image description here