<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ABFS Authentication with a SAS token -&amp;gt; 403! in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/100830#M40435</link>
    <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I'm running a streamReader/Writer with autoloader from StorageV2 (general purpose v2) over &lt;STRONG&gt;abfss&lt;/STRONG&gt; instead of &lt;STRONG&gt;wasbs. &lt;/STRONG&gt;My checkpoint location is valid, the reader properly reads the file schema and autoloader is able to sample 105 files to do so.&lt;/P&gt;&lt;P&gt;I have a valid SAS token with all permissions set, the storage is not behind a firewall and is open to access from all networks. However, whenever I try to access the storage location with abfss I get the following error:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN class=""&gt;(shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException) Operation failed: "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.", 403&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The SAS token is set like this:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;spark.conf.set("fs.azure.account.auth.type.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", "SAS")&lt;BR /&gt;spark.conf.set("fs.azure.sas.token.provider.type.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.sas.FixedSASTokenProvider")&lt;BR /&gt;spark.conf.set("fs.azure.sas.fixed.token.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", &amp;lt;sas_token&amp;gt;)&lt;/P&gt;&lt;P&gt;I am currently running: 15.4 LTS (includes Apache Spark 3.5.0, Scala 2.12) with Azure Data Lake Storage credential passthrough enabled. Soft blob delete is disabled on the storage account and the SAS token has all the possible permissions.&lt;/P&gt;&lt;P&gt;The same operation and setup work with wasbs, leaving me wondering what could be the possible reasons and how to fix them. If anyone encountered this issue or knows how to solve it without using Azure Service Principal, I would appreciate the help. I've spent way too much time on this with no real solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Dec 2024 21:06:21 GMT</pubDate>
    <dc:creator>willie_nelson</dc:creator>
    <dc:date>2024-12-03T21:06:21Z</dc:date>
    <item>
      <title>ABFS Authentication with a SAS token -&gt; 403!</title>
      <link>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/100830#M40435</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I'm running a streamReader/Writer with autoloader from StorageV2 (general purpose v2) over &lt;STRONG&gt;abfss&lt;/STRONG&gt; instead of &lt;STRONG&gt;wasbs. &lt;/STRONG&gt;My checkpoint location is valid, the reader properly reads the file schema and autoloader is able to sample 105 files to do so.&lt;/P&gt;&lt;P&gt;I have a valid SAS token with all permissions set, the storage is not behind a firewall and is open to access from all networks. However, whenever I try to access the storage location with abfss I get the following error:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN class=""&gt;(shaded.databricks.azurebfs.org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException) Operation failed: "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.", 403&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The SAS token is set like this:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;spark.conf.set("fs.azure.account.auth.type.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", "SAS")&lt;BR /&gt;spark.conf.set("fs.azure.sas.token.provider.type.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.sas.FixedSASTokenProvider")&lt;BR /&gt;spark.conf.set("fs.azure.sas.fixed.token.&amp;lt;storage_account&amp;gt;.dfs.core.windows.net", &amp;lt;sas_token&amp;gt;)&lt;/P&gt;&lt;P&gt;I am currently running: 15.4 LTS (includes Apache Spark 3.5.0, Scala 2.12) with Azure Data Lake Storage credential passthrough enabled. Soft blob delete is disabled on the storage account and the SAS token has all the possible permissions.&lt;/P&gt;&lt;P&gt;The same operation and setup work with wasbs, leaving me wondering what could be the possible reasons and how to fix them. If anyone encountered this issue or knows how to solve it without using Azure Service Principal, I would appreciate the help. I've spent way too much time on this with no real solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Dec 2024 21:06:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/100830#M40435</guid>
      <dc:creator>willie_nelson</dc:creator>
      <dc:date>2024-12-03T21:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: ABFS Authentication with a SAS token -&gt; 403!</title>
      <link>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/100891#M40465</link>
      <description>&lt;P&gt;Resolved it with Service Principal.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 11:14:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/100891#M40465</guid>
      <dc:creator>willie_nelson</dc:creator>
      <dc:date>2024-12-04T11:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: ABFS Authentication with a SAS token -&gt; 403!</title>
      <link>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/101421#M40655</link>
      <description>&lt;P&gt;Would you mind to paste the sample code please. I am trying to use abfs with autoloader and getting error like yours.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 07:37:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/101421#M40655</guid>
      <dc:creator>BricksGuy</dc:creator>
      <dc:date>2024-12-09T07:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: ABFS Authentication with a SAS token -&gt; 403!</title>
      <link>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/101715#M40784</link>
      <description>&lt;P&gt;Hi BricksGuy,&lt;BR /&gt;&lt;BR /&gt;So I created a service principal in the portal for my user which results in a client id, and secret. You also need the tenant_id.&lt;/P&gt;&lt;P&gt;Then you can set your spark options as below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spark.conf.set(f"fs.azure.account.auth.type.{storage_account_name}.dfs.core.windows.net", "OAuth")
spark.conf.set(f"fs.azure.account.oauth.provider.type.{storage_account_name}.dfs.core.windows.net", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider")
spark.conf.set(f"fs.azure.account.oauth2.client.id.{storage_account_name}.dfs.core.windows.net", &amp;lt;sp_client_id&amp;gt;)
spark.conf.set(f"fs.azure.account.oauth2.client.secret.{storage_account_name}.dfs.core.windows.net", "&amp;lt;sp_secret&amp;gt;")
spark.conf.set(f"fs.azure.account.oauth2.client.endpoint.{storage_account_name}.dfs.core.windows.net", "https://login.microsoftonline.com/&amp;lt;tenant_id&amp;gt;/oauth2/token")&lt;/LI-CODE&gt;&lt;P&gt;Make sure to use DFS and not Blob for the endpoint keys, otherwise spark will get confused and you'll get a similar problem with either the method not being allowed or the headers not set correctly.&lt;/P&gt;&lt;P&gt;Once this has executed, you can access your storage. To verify, I just list the dirs as below:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;directories = dbutils.fs.ls(f"abfss://{container_name}@{storage_account_name}.dfs.core.windows.net/{main_path}")&lt;/LI-CODE&gt;&lt;P&gt;It took me a couple of days to get from a standstill to here. I'm using the 14.3 Runtime. I found most online resources to work better with that runtime version.&lt;/P&gt;&lt;P&gt;Good luck and let me know if I can help you further.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 09:06:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/abfs-authentication-with-a-sas-token-gt-403/m-p/101715#M40784</guid>
      <dc:creator>willie_nelson</dc:creator>
      <dc:date>2024-12-11T09:06:17Z</dc:date>
    </item>
  </channel>
</rss>

