Microsoft.WindowsAzure.Storage.StorageException: 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'

Augusto Emanuelli 0 Reputation points
2023-03-10T16:20:13.3266667+00:00

Hi, I'm trying to upload a file to a blob storage using Access keys

Here is my code:

            // Retrieve storage account from connection string.
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName={
AccountName};AccountKey={AccountKey};EndpointSuffix=core.windows.net");

            // Create the blob client.
            CloudBlobClient blobClient = StorageAccount.CreateCloudBlobClient();

            // Retrieve reference to a previously created container.
            CloudBlobContainer container = blobClient.GetContainerReference("files");
            // Create the container if it doesn't already exist.
            await container.CreateIfNotExistsAsync();

The problem is when i'm calling the CreateIfNotExistsAsync method.... i already check the keys and are correct, and i tried with several time zones.... (i'm in Argentina, not sure if the ip may be a problem)

Microsoft.WindowsAzure.Storage.StorageException: 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.'

There is any way to set the Authorization header using the Microsoft.WindowsAzure.Storage tools? Because i was thinking into make the request via httpclient....

Any idea? Workaround? Thanks

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,428 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SaiKishor-MSFT 17,186 Reputation points
    2023-03-20T23:16:35.47+00:00

    @Augusto Emanuelli Thanks for reaching out to Microsoft Q&A.

    Can you confirm if AllowSharedKeyAccess is enabled or disabled?

    Please refer-

    https://learn.microsoft.com/en-us/azure/storage/common/shared-key-authorization-prevent?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json&tabs=portal#understand-how-disallowing-shared-key-affects-sas-tokens

    When you disallow Shared Key authorization for a storage account, Azure Storage rejects all subsequent requests to that account that are authorized with the account access keys. Only secured requests that are authorized with Azure AD will succeed. For more information about using Azure AD, see Authorize access to data in Azure Storage.

    Can you also confirm the access keys were not refreshed etc., by confirming they match with the keys in the Portal?

    Do you also have one of the below roles assigned to you for access?

    Please let me know. Regarding your question- "There is any way to set the Authorization header using the Microsoft.WindowsAzure.Storage tools? Because i was thinking into make the request via httpclient...."-

    I am looking into this and will get back to you soon. Thank you!

    0 comments No comments