質問

When trying to do a batch insert to Azure Table Storage, I am getting a StorageException on CloudTable.ExecuteBatch():

TableBatchOperation batchOperation = new TableBatchOperation();

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

table.ExecuteBatch(batchOperation);

Exception thrown:

Microsoft.WindowsAzure.Storage.StorageException: Unexpected response code for operation : 6 at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](StorageCommandBase1 cmd, IRetryPolicy policy, OperationContext operationContext) in e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Core\Executor\Executor.cs:line 737 at Microsoft.WindowsAzure.Storage.Table.TableBatchOperation.Execute(CloudTableClient client, String tableName, TableRequestOptions requestOptions, OperationContext operationContext) in e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Table\TableBatchOperation.cs:line 85 at Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteBatch(TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) in e:\projects\azure-sdk-for-net\microsoft-azure-api\Services\Storage\Lib\DotNetCommon\Table\CloudTable.cs:line 165 at Library.Modules.Cloud.TableStorage.StorageTableRepository1.InsertOrReplaceBatch(List1 entities)

Inserting these entities normally using TableOperation gives me no problems.

I cannot find this exception anywhere on the internet or in the MSDN references.

役に立ちましたか?

解決

It was due to duplicate RowKey values. Even with TableBatchOperation.InsertOrReplace(entities), the row keys still need to be unique.

Unexpected response code for operation : 6 was referring to the 6th element in the list. The error codes in the Azure SDK are very misleading in my opinion.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top