Azure Blob Storage fails to authenticate: "Make sure the value of Authorization header is formed correctly including the signature"

javier 926 Reputation points
2021-03-28T22:05:03.557+00:00

Hi I am trying to upload a binary file (a blob for an excel file, actually) to my storage account but the client fails to authenticate under the error message: 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)

Note that:

  • SAS key is being generated successfully
  • Blob service client is being generated using uri coming from SAS key generation response (so I believe it has the correct format
  • Angular app with "@azure/storage-blob": "^12.5.0"

Would much appreciate any help on this one

async uploadFileToAzure(file : Blob, filename : string){

    let params = {
      "filename": filename, 
      "container" : 'attachments', 
      'connkey' : 'xxx'
    };

    this._authService.getSAS(params).subscribe(async sas=>{

      var blobUri = 'https://xxx.blob.core.windows.net/';
      const blobServiceClient = new BlobServiceClient(`${sas["uri"]}`);
      const containerClient = blobServiceClient.getContainerClient(params["container");
      const blockBlobClient = containerClient.getBlockBlobClient(filename);

      const uploadBlobResponse = await blockBlobClient.upload(file, file.size);
      console.log(`Upload block blob successfully`, uploadBlobResponse.requestId);
    })
  };

Thanks

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,552 questions
{count} votes

Accepted answer
  1. shiva patpi 13,156 Reputation points Microsoft Employee
    2021-03-29T03:24:51.467+00:00

    Hello @javier ,
    Thanks for your query !
    Can you validate if your storage account is firewall enabled ?

    Steps:-
    Azure Portal -> Storage Account -> Networking -> Check Allow Access From (All Networks / Selected Networks)
    If it is "Selected Networks" - It means the storage account is firewall enabled.

    If the storage account is firewall enabled , check your angular app is whitelisted to access.

    Couple of additional work arounds mentioned here
    https://stackoverflow.com/questions/24492790/azurestorage-blob-server-failed-to-authenticate-the-request-make-sure-the-value

    Let us know if the above steps helps out in resolving the issue , please don't forget to Upvote and Accept the Answer

    3 people found this answer helpful.

9 additional answers

Sort by: Most helpful
  1. AzRobo 16 Reputation points
    2021-11-11T02:51:47.553+00:00

    check the SAS signature key generated is prefixed with "?" at the beginning.
    for example SAS key should be like "**?**sp=racwdlmeop&st***********************"

    1 person found this answer helpful.

  2. Antara Das 376 Reputation points
    2021-11-30T10:46:20.717+00:00

    Have the same eror when trying to load the data as a pandas dataframe : Dataset.to_pandas_dataframe()

    Execution failed in operation 'to_pandas_dataframe' for Dataset(id='data id', name='dataset name', error_code=ScriptExecution.StreamAccess.Authentication,error_message=ScriptExecutionException was caused by StreamAccessException.
    StreamAccessException was caused by AuthenticationException.
    Authentication failed for 'AzureBlob GetReference' operation at '[REDACTED]' with '403: AuthenticationFailed'. Please make sure the SAS token or the account key is correct.
    Failed due to inner exception of type: StorageException

    0 comments No comments

  3. Baomei Fan (PACTERA TECHNOLOGIES INC) 26 Reputation points Microsoft Vendor
    2023-08-24T22:18:06.2666667+00:00

    I got same error. In my situation it turned out due to the expiration time for the sas was incorrectly using local time, while Azure is using UTC time. After updating to use UTC time, it works.

    0 comments No comments

  4. Suwarna S Kale 301 Reputation points
    2024-03-12T12:33:31.3966667+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    From the screenshot and error details provided by you, it seems like you are encountering an authentication issue while trying to upload a binary file (an Excel blob) to your Azure storage account

    You may need to ensure that the SAS token you generated has the necessary permissions for uploading blobs. Specifically, it should have the Write permission. Verify that the SAS token is correctly appended to the URI when creating the blob service client.

    Just an alternative which may help here, Instead of using SAS tokens, consider using managed identity for authentication. This approach allows your application to authenticate directly with Azure services.

    Does the response help answer your question? Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution. Thanks 🙂

    0 comments No comments