来自CloudTable.ExecuteBatch(..)的意外响应代码

Dav*_*New 9 c# azure azure-storage azure-table-storage

当试图做一个批量插入到Azure的表存储,我得到一个StorageExceptionCloudTable.ExecuteBatch():

TableBatchOperation batchOperation = new TableBatchOperation();

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

table.ExecuteBatch(batchOperation);
Run Code Online (Sandbox Code Playgroud)

抛出异常:

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

通常使用插入这些实体TableOperation不会给我带来任何问题.

我无法在互联网或MSDN参考中的任何地方找到此异常.

Dav*_*New 15

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

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

  • 错误代码确实具有误导性.我整理了[使用Fiddler调试此错误的指南](http://amadeusw.com/debugging/debugging-azure-with-fiddler/).用它来查找有意义的错误信息.就我而言,我发送的数据太大了. (2认同)