【问题标题】:Unexpected response code from CloudTable.ExecuteBatch(..)来自 CloudTable.ExecuteBatch(..) 的意外响应代码
【发布时间】:2013-11-27 10:00:04
【问题描述】:

当尝试对 Azure 表存储进行批量插入时,我在 CloudTable.ExecuteBatch() 上收到了一个 StorageException

TableBatchOperation batchOperation = new TableBatchOperation();

foreach (var entity in entities)
{
    batchOperation.InsertOrReplace(entity);
}

table.ExecuteBatch(batchOperation);

抛出异常:

Microsoft.WindowsAzure.Storage.StorageException:意外响应 操作代码:6 at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase1 cmd, IRetryPolicy 策略, OperationContext operationContext) 中 e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Core\Executor\Executor.cs:line 737 在 Microsoft.WindowsAzure.Storage.Table.TableBatchOperation.Execute(CloudTableClient 客户端,字符串 tableName,TableRequestOptions requestOptions, OperationContext operationContext) 中 e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Table\TableBatchOperation.cs:line 85 在 Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteBatch(TableBatchOperation 批处理,TableRequestOptions requestOptions,OperationContext 操作上下文)在 e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Table\CloudTable.cs:line 165 在 Library.Modules.Cloud.TableStorage.StorageTableRepository1.InsertOrReplaceBatch(List1 实体)

使用TableOperation 正常插入这些实体没有问题。

我在 Internet 上的任何地方或 MSDN 参考资料中都找不到此异常。

【问题讨论】:

  • 您能否检查批次中的所有实体 1) 是否具有相同的 PartitionKey 和 2) 一个实体在批次中没有重复多次。根据错误消息,查看批次中的第 7 个实体。该实体正在引起问题。

标签: c# azure azure-storage azure-table-storage


【解决方案1】:

这是由于重复的 RowKey 值。即使使用TableBatchOperation.InsertOrReplace(entities),行键仍然需要是唯一的。

Unexpected response code for operation : 6 指的是列表中的第 6 个元素。在我看来,Azure SDK 中的错误代码非常具有误导性。

【讨论】:

  • 错误代码确实具有误导性。我整理了一个guide to using Fiddler to debug this error。使用它来查找有意义的错误信息。就我而言,我发送的数据太大了。
  • @AmadeuszWieczorek 可以确认。链接已损坏。
  • 我的博客引擎有问题,现在已解决。感谢您的提醒!该链接现在可以使用了。
猜你喜欢
  • 2020-08-03
  • 2018-05-16
  • 2014-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-16
相关资源
最近更新 更多