title: Azure Blob: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature
body: <p>Can someone please assist me? I am getting below error while accessing blob container by using SAS token with storage emulator -</p>
  <blockquote>
  <p><strong>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature</strong></p>
  <p>System.AggregateException: One or more errors occurred. (Server failed
  to authenticate the request. Make sure the value of Authorization
  header is formed correctly including the signature.
  RequestId:c3d554bf-ae0c-413d-ba15-ef888f141864
  Time:2020-08-19T08:18:01.6796671Z Status: 403 (Server failed to
  authenticate the request. Make sure the value of Authorization header
  is formed correctly including the signature.) ErrorCode:
  AuthenticationFailed</p>
  <p>Headers: Server: Microsoft-HTTPAPI/2.0 x-ms-request-id:
  c3d554bf-ae0c-413d-ba15-ef888f141864 x-ms-error-code:
  AuthenticationFailed Date: Wed, 19 Aug 2020 08:18:01 GMT
  Content-Length: 498 Content-Type: application/xml**</p>
  <p>Expected behavior What is the expected behavior?</p>
  <p>Below are the Exception or Stack Trace details -
  ---&gt; Azure.RequestFailedException: Server failed to authenticate the request. Make sure the value of Authorization header is formed
  correctly including the signature.
  RequestId:0b506bfc-ba50-4519-924f-6072c5ba829d
  Time:2020-08-19T08:47:57.3367759Z Status: 403 (Server failed to
  authenticate the request. Make sure the value of Authorization header
  is formed correctly including the signature.) ErrorCode:
  AuthenticationFailed</p>
  <p>Headers: Server: Microsoft-HTTPAPI/2.0 x-ms-request-id:
  0b506bfc-ba50-4519-924f-6072c5ba829d x-ms-error-code:
  AuthenticationFailed Date: Wed, 19 Aug 2020 08:47:57 GMT
  Content-Length: 498 Content-Type: application/xml</p>
  <p>at
  Azure.Storage.Blobs.BlobRestClient.Service.GetPropertiesAsync_CreateResponse(ClientDiagnostics
  clientDiagnostics, Response response) at
  Azure.Storage.Blobs.BlobRestClient.Service.GetPropertiesAsync(ClientDiagnostics
  clientDiagnostics, HttpPipeline pipeline, Uri resourceUri, String
  version, Nullable`1 timeout, String requestId, Boolean async, String
  operationName, CancellationToken cancellationToken) at
  Azure.Storage.Blobs.BlobServiceClient.GetPropertiesInternal(Boolean
  async, CancellationToken cancellationToken) at
  Azure.Storage.Blobs.BlobServiceClient.GetPropertiesAsync(CancellationToken
  cancellationToken)</p>
  </blockquote>
  <p>I am referring sample example - <a href="https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs" rel="nofollow noreferrer">https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs</a></p>
  <p>Below is the code to reproduce -</p>
  <pre><code>BlobSasBuilder sasBuilder = new BlobSasBuilder {
  BlobContainerName = &quot;myTestContainer&quot;,
  Resource = &quot;c&quot;,
  //StartsOn = DateTimeOffset.UtcNow,
  //ExpiresOn = DateTimeOffset.UtcNow.AddHours(1)
  ExpiresOn = DateTimeOffset.MaxValue
  };  
  //Allow read access
          sasBuilder.SetPermissions(BlobContainerSasPermissions.Read);
          
          StorageSharedKeyCredential credential =
              new StorageSharedKeyCredential(&quot;Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==&quot;, &quot;devstoreaccount1&quot;);
  
          // Use the key to get the SAS token.
          string sasToken = sasBuilder.ToSasQueryParameters(credential).ToString();
  
          Console.WriteLine(&quot;SAS for blob container is: {0}&quot;, sasToken);
          Console.WriteLine();
  
          // Build a SAS URI
          UriBuilder sasUri = new UriBuilder(containerClient.Uri);
          sasUri.Query = sasToken;
  
          // Create a client that can authenticate with the SAS URI
          BlobServiceClient service = new BlobServiceClient(sasUri.Uri);
          
           // Make a service request to verify we've successfully authenticated
          await service.GetPropertiesAsync(); //Note - Receiving above error while calling this function
  </code></pre>