繁体   English   中英

Azure.Storage.Blobs 支持 localDevelopment 抛出 HTTP 标头之一的值格式不正确

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

从 Microsoft.Azure.Blob 升级到 Azure.Storage.Blobs 后,我正在尝试通过一些单元测试。 我与 BlobServiceClient 的连接是

    //   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); 

想知道是否有人知道使用 azurite 和最新的库是否有一些限制? 检查我的容器,它在我看来“没问题”吗? 我也尝试使用 Microsoft Azure 存储资源管理器中提供的连接字符串,但遇到了同样的问题。 我不明白我的标头不正确是什么意思。 其他答案都与功能有关,而且还有 4 岁。 我觉得这个问题与我的单元测试设置有关。

blob服务客户端

blobContainerClient

实际错误信息:

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

发生此错误是因为您安装的 Azurite (v3.17.1) 支持的存储 REST API 版本不是您正在使用的 SDK (12.14.1) 版本支持的最新版本 REST API。

要解决此问题,有几个选项:

  • 将您的 Azurite 安装更新到最新版本。 查看 Azurite版本,REST API 版本 2021-10-04 支持包含在版本 3.19.0 中。
  • 如果可能,使用云存储进行开发。 这样您就不会遇到这些版本控制问题。
  • 虽然不推荐,但如果您想继续使用 Azurite 3.17.1 版,则需要将 SDK 降级到支持相同 REST API 版本的版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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