question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AuthenticationFailed when using SAS token based authentication to read Azure Table

See original GitHub issue

I have been using the snippet below to create and Azure.Data.Tables:12.1.0 and having intermittent authentication failure. I have tried to setup start date to -1 day and also tried without start date. It works once out of 4 times.

Error:

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:cf1c3480-2002-0069-32cf-7c6cb1000000
Time:2021-07-19T18:52:47.4799506Z
Status: 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)
ErrorCode: AuthenticationFailed

Content:
{"odata.error":{"code":"AuthenticationFailed","message":{"lang":"en-US","value":"Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:cf1c3480-2002-0069-32cf-7c6cb1000000\nTime:2021-07-19T18:52:47.4799506Z"}}}

Headers:
x-ms-request-id: cf1c3480-2002-0069-32cf-7c6cb1000000
x-ms-error-code: REDACTED
Content-Length: 299
Content-Type: application/json
Date: Mon, 19 Jul 2021 18:52:46 GMT
Server: Microsoft-HTTPAPI/2.0

Snippet:

      
       private static string connectionString(string sasKey)
        {
            string tableEndpoint = $"https://{StorageAccountName}.{TableStorageBaseURI}/";
            string connecitonString1 = $"TableEndpoint={tableEndpoint};SharedAccessSignature={sasKey}";

            return connecitonString1;
        }

        private static string GetAccountSASToken(StorageSharedKeyCredential key)
        {
            // Create a SAS token that's valid for one hour.
            AccountSasBuilder sasBuilder = new AccountSasBuilder()
            {
                Services = AccountSasServices.Tables,
                ResourceTypes = AccountSasResourceTypes.All,
                ExpiresOn = DateTimeOffset.UtcNow.AddHours(1),
                Protocol = SasProtocol.Https,
                StartsOn = DateTimeOffset.UtcNow.AddDays(-1)
            };

            sasBuilder.SetPermissions(AccountSasPermissions.Read |
                AccountSasPermissions.Write);

            // Use the key to get the SAS token.
            string sasToken = sasBuilder.ToSasQueryParameters(key).ToString();

            Console.WriteLine("SAS token for the storage account is: {0}", sasToken);
            Console.WriteLine();

            return sasToken;
        }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
christothescommented, Aug 10, 2021

I should have a PR out in the next couple days for this.

0reactions
msftbot[bot]commented, Aug 25, 2021

Hi @snehitgajjar, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot access to URI SAS blob storage AuthenticationFailed
im trying to access to a specific blob by URI SAS but i got error AuthenticationErrorDetail, is there anything im doing wrong here?...
Read more >
Azure storage SAS failed to authenticate
Hi I am trying to create SAS token for my file on Azure. I am getting "Server failed to authenticate the request. Make...
Read more >
Getting Authentication Error while accessing Azure Blob ...
Solved: I am trying to access the Azure Blob table using Pyspark but getting an Authentication Error. Here I am passing SAS token...
Read more >
Azure/azure-storage-azcopy - Authentication Failed
In theory, I just need to use command: azcopy copy "path" "SAStoken" If I run this command directly from Cmd, it's working fine....
Read more >
Microsoft.Azure.Storage.StorageException: Server failed to ...
Microsoft.Azure.Storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found