AuthenticationFailed when using SAS token based authentication to read Azure Table
See original GitHub issueI 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:
- Created 2 years ago
- Comments:18 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I should have a PR out in the next couple days for this.
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.