简体   繁体   中英

Azure.Storage.Blobs support for localDevelopment throws The value for one of the HTTP headers is not in the correct format

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.

blob服务客户端

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM