2013-11-14 21 views
7

Khi cố gắng để làm một chèn hàng loạt để Azure Table Storage, Tôi nhận được một StorageException trên CloudTable.ExecuteBatch():mã phản hồi không mong đợi từ CloudTable.ExecuteBatch (..)

TableBatchOperation batchOperation = new TableBatchOperation(); 

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

table.ExecuteBatch(batchOperation); 

ngoại lệ ném:

Microsoft.WindowsAzure.Storage.StorageException: Phản hồi không mong muốn mã hoạt động: 6 tại Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync [T] (StorageCommandBase1 cmd, chính sách IRetryPolicy, hoạt động OperationContextContext) trong e: \ projects \ azure-sdk-cho-net \ microsoft-azure-api \ Dịch vụ \ Storage \ Lib \ DotNetCommon \ Core \ Executor \ Executor.cs: dòng 737 lúc Microsoft.WindowsAzure.Storage.Table.TableBatchOperation.Execute (CloudTableClient khách hàng, String tableName, TableRequestOptions requestOptions, OperationContext operationContext) in e: \ projects \ azure-sdk-for-net \ microsoft-azure-api \ Services \ Lưu trữ \ Lib \ DotNetCommon \ Bảng \ TableBatchOperation.cs: dòng 85 tại Microsoft.WindowsAzure.Storage.Table.CloudTable.ExecuteBatch (TableBatchOperation batch, TableRequestOptions requestOptions, OperationContext operationContext) in e: \ projects \ azure-sdk-for-net \ microsoft-azure-api \ Dịch vụ \ Storage \ Lib \ DotNetCommon \ Table \ CloudTable.cs: dòng 165 tại Library.Modules.Cloud.TableStorage.StorageTableRepository đối tượng)

Chèn các thực thể này thông thường bằng cách sử dụng TableOperation không mang lại sự cố nào.

Tôi không thể tìm thấy ngoại lệ này ở bất kỳ đâu trên internet hoặc trong tài liệu tham khảo MSDN.

+3

Bạn có thể kiểm tra xem tất cả các thực thể trong lô 1) có cùng PartitionKey và 2) một thực thể không được lặp lại nhiều lần trong lô. Dựa trên thông báo lỗi, hãy nhìn vào thực thể thứ 7 trong lô của bạn. Thực thể đó đang gây ra vấn đề. –

Trả lời

14

Đó là do trùng lặp RowKey giá trị. Ngay cả với TableBatchOperation.InsertOrReplace(entities), các phím hàng vẫn cần phải là duy nhất.

Unexpected response code for operation : 6 đề cập đến phần tử thứ 6 trong danh sách. Các mã lỗi trong Azure SDK là rất sai lầm trong quan điểm của tôi.

+2

Các mã lỗi thực sự gây hiểu nhầm. Tôi đặt cùng một [hướng dẫn sử dụng Fiddler để gỡ lỗi này] (http://amadeusw.com/debugging/debugging-azure-with-fiddler/). Sử dụng nó để tìm thông tin lỗi có ý nghĩa. Trong trường hợp của tôi, dữ liệu tôi gửi quá lớn. –

+0

liên kết bị hỏng: ( –

+0

@AmadeuszWieczorek Có thể xác nhận .Liên kết bị hỏng – sharptooth

Các vấn đề liên quan