1

I am trying get past some unit test after upgrading from Microsoft.Azure.Blob to Azure.Storage.Blobs. My connection to BlobServiceClient is

    //   create service client: 
    var blobServiceClient = BlobServiceClient("UseDevelopmentStorage=true")
    //create container
    BlobContainerClient container = client.GetBlobContainerClient(containerName);
                
     //my code blows up on 'container.exists()'...but I don't get read access error.
     //RequestFailedException : "The value for one of the HTTP headers is not in the correct format." 
     if(!container.Exists())
           container = client.CreateBlobContainer(containerName).Value;
                
                BlobClient blobClient = container.GetBlobClient($"{blobName}.json");
               await blobClient.UploadAsync(BinaryData.FromString(jsonContent), options); 

Wondering if anyone knows if there is some limitation on using azurite and the latest libs? checking my container it 'looks' to me like it is ok? I have tried using the provided connection strings from within Microsoft Azure Storage explorer as well and had the same issues. I can't understand what it means by my headers are incorrect. The other answers are related to functions and also gt 4 years old. I feel like this issue is something to do with my unit test setup.

blobServiceClient

blobContainerClient

The actual error message:

The value for one of the HTTP headers is not in the correct format.
RequestId:5b9f9072-606b-4dfa-b174-19ef2fa2c20d
Time:2023-01-27T00:02:23.357Z
Status: 400 (The value for one of the HTTP headers is not in the correct format.)
ErrorCode: InvalidHeaderValue

Additional Information:
HeaderName: x-ms-version
HeaderValue: 2021-10-04

Content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
  <Code>InvalidHeaderValue</Code>
  <Message>The value for one of the HTTP headers is not in the correct format.
RequestId:5b9f9072-606b-4dfa-b174-19ef2fa2c20d
Time:2023-01-27T00:02:23.357Z</Message>
  <HeaderName>x-ms-version</HeaderName>
  <HeaderValue>2021-10-04</HeaderValue>
</Error>

Headers:
Server: Azurite-Blob/3.17.1
x-ms-error-code: InvalidHeaderValue
x-ms-request-id: 5b9f9072-606b-4dfa-b174-19ef2fa2c20d
Date: Fri, 27 Jan 2023 00:02:23 GMT
Connection: keep-alive
Keep-Alive: REDACTED
Transfer-Encoding: chunked
Content-Type: application/xml
James Z
  • 12,209
  • 10
  • 24
  • 44
macm
  • 544
  • 7
  • 21
  • `Wondering if anyone knows if there is some limitation on using azurite and the latest libs ?` - this could very well be the reason. What's the version of Azurite and SDK you are using? – Gaurav Mantri Jan 27 '23 at 03:34
  • using Azurite 3.17.1 using "Azure.Storage.Blobs" Version="12.14.1" its annoying this doesn't just work. makes me doubt the implementation. When I use an actual azure connection string against an azure storage , the code runs fine. – macm Jan 27 '23 at 03:43

1 Answers1

0

The error is happening because the Storage REST API version supported by your installation of Azurite (v3.17.1) is not the latest REST API version which is supported by the version of SDK (12.14.1) you are using.

To fix this issue, there are a few options:

  • Update your installation of Azurite to the latest version. Looking at Azurite releases, REST API version 2021-10-04 support is included in version 3.19.0.
  • Use cloud storage for development if possible. That way you will not run into these versioning issues.
  • Though not recommended but if you want to keep on using version 3.17.1 of Azurite, you would need to downgrade the SDK to a version that has support for the same REST API version.
Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • Thanks Gaurav. This is the answer. This is a related answer as well: https://stackoverflow.com/questions/71558801/visual-studio-2022-with-azurite-integrated-v3-14-1-in-creation-of-local-blob-c#:~:text=Two%20possible%20solutions%3A%20Upgrade%20the%20Azurite%20version%3A%20If,latest%20version%20of%20Azurite.%20npm%20update%20-g%20azurite – macm Jan 27 '23 at 15:01