gpt4 book ai didi

使用模拟存储时出现 Azure StorageException(在记录的限制范围内)

转载 作者:行者123 更新时间:2023-12-01 06:01:41 26 4
gpt4 key购买 nike

我们的应用程序执行多批TableBatchOperation。我们确保每个表批处理操作都有

  • 100 或更少的表操作
  • 仅对一个实体分区键进行表操作

大致如下:

        foreach (var batch in batches)
{
var operation = new TableBatchOperation();
operation.AddRange(batch.Select(x => TableOperation.InsertOrReplace(x)));
await table.ExecuteBatchAsync(operation);
}
  • 当我们使用模拟存储时,我们会遇到Microsoft.WindowsAzure.Storage.StorageException - “批处理中的元素 99 返回了意外的响应代码。”<
  • 当我们使用生产版 Azure 时,一切正常。

模拟存储配置如下:

<add key="StorageConnectionString" value="UseDevelopmentStorage=true;" />

我担心,尽管在生产环境中(我们使用真正的 Azure)一切正常,但模拟存储导致的崩溃可能表明我们做了不应该做的事情。

我已经使用调试器运行了它(在它崩溃之前)并验证了这一点(根据 API):

  • 序列化为 JSON 后,整个操作只有 492093 个字符(UTF-16 为 984186 字节)
  • 正好有 100 个操作
  • 所有实体都具有相同的分区键

参见https://learn.microsoft.com/en-us/dotnet/api/microsoft.windowsazure.storage.table.tablebatchoperation?view=azurestorage-8.1.3

编辑:看起来其中一项 (#71/100) 导致此失败。从结构上来说,它与其他项目没有什么不同,但是它确实有一些相当长的字符串属性 - 所以也许存在未记录的限制/错误?

编辑:以下 Unicode UTF-16 字节序列(在字符串属性上)足以导致异常:

r     e     n     U+0019         space
114 0 101 0 110 0 25 0 115 0 32 0

(字节 25 0 115 0 即 unicode end-of-medium U+0019 导致了异常)。

编辑:失败实体的完整示例:

JSON:

{"SomeProperty":"ren\u0019s ","PartitionKey":"SomePartitionKey","RowKey":"SomeRowKey","Timestamp":"0001-01-01T00:00:00+00:00","ETag":null}

实体类:

public class TestEntity : TableEntity
{
public string SomeProperty { get; set; }
}

实体对象构造:

var entity = new TestEntity
{
SomeProperty = Encoding.Unicode.GetString(new byte[]
{114, 0, 101, 0, 110, 0, 25, 0, 115, 0, 32, 0}),
PartitionKey = "SomePartitionKey",
RowKey = "SomeRowKey"
};

最佳答案

根据您的描述,我也可以重现您提到的问题。经过我测试发现特别Azure 存储模拟器似乎不支持 Unicode 字符“END OF MEDIUM”(U+0019)。如果可以替换为其他unicode,请尝试使用其他unicode来代替。

我们也可以给我们的 feedback Azure 存储团队。

关于使用模拟存储时出现 Azure StorageException(在记录的限制范围内),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44754425/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com