Probem accessing blob with databricks using SAS

alexis 101 Reputation points
2022-11-17T09:59:12.433+00:00

Hi,
I am trying to access my blob with Databricks through SAS.

In my spark code I use

spark.conf.set("fs.azure.account.auth.type.<storage-account>.dfs.core.windows.net", "SAS")
spark.conf.set("fs.azure.sas.token.provider.type.<storage-account>.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.sas.FixedSASTokenProvider")
spark.conf.set("fs.azure.sas.fixed.token.<storage-account>.dfs.core.windows.net", "<token>")

and then my

df = spark.read.csv("abfs://<container-name>@<storage-account>.dfs.core.windows.net/<file-path>")

When I try to run the csv I get following msg:

Operation failed: "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.", 403, HEAD, https://safobapreprddwh.dfs.core.windows.net/configurations/?upn=false&action=getAccessControl&timeout=90&sv=2021-06-08&ss=b&srt=s&sp=rwdlaciytfx&se=2022-11-17T17:52:13Z&st=2022-11-17T09:52:13Z&spr=https&sig=XXXX

I have seen that many ppl have faced similar problem and I have tried their solution without any success.

This is what I have done so far:
Storage account name is taken from here
261368-image.png

In storage account I go to Security + networking section and generate SAS token
261279-image.png

My container name and blob are:
261345-image.png

with those values I put them in my spark conf and try to read my csv:

spark.conf.set("fs.azure.account.auth.type.safobapreprddwh.dfs.core.windows.net", "SAS")
spark.conf.set("fs.azure.sas.token.provider.type.safobapreprddwh.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.sas.FixedSASTokenProvider")
spark.conf.set("fs.azure.sas.fixed.token.safobapreprddwh.dfs.core.windows.net", "sv=2021-06-08&ss=bfqt&sr<My_SAS_Token>")
df = spark.read.csv("abfs://******@safobapreprddwh.dfs.core.windows.net/Days.csv")

Do I need to configure something?

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha 19,547 Reputation points Microsoft Employee Moderator
    2022-11-18T19:53:13.16+00:00

    Hello @alexis ,
    Thanks for the question and using MS Q&A platform.
    As we understand the ask here is how to get the rid of the above error , please do let us know if its not accurate.
    You are on the right path when you removed "?" from the token .
    I was able to repro the error and i found that the if you do not Select the Object while creating the SAS , we have this error .

    261960-image.png

    Please do let me if you have any queries.
    Thanks
    Himanshu


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.