【发布时间】:2020-10-29 00:30:33
【问题描述】:
我的容器上有以下分区 ID: /vesselId
我正在尝试添加此对象的集合:
public class CoachVessel
{
[JsonProperty("id")]
public string vesselId { get; set; }
[JsonProperty("imo")]
public long Imo { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
这是我批量插入文档的代码:
CosmosClientOptions options = new CosmosClientOptions() { AllowBulkExecution = true };
CosmosClient cosmosclient = new CosmosClient(connStr, options);
Container container = cosmosclient.GetContainer("CoachAPI", "Vessels");
List<Task> concurrentTasks = new List<Task>();
foreach (var vessel in vessels.Take(1))
{
concurrentTasks.Add(container.CreateItemAsync(vessel, new PartitionKey(vessel.vesselId)));
}
await Task.WhenAll(concurrentTasks);
我收到以下未提供太多信息的错误?
Microsoft.Azure.Cosmos.CosmosException: '响应状态码不 表示成功:BadRequest (400);子状态:1001;活动ID:; 原因:();'
我在删除文档时遇到同样的问题:
CosmosClientOptions options = new CosmosClientOptions() { AllowBulkExecution = true, MaxRetryAttemptsOnRateLimitedRequests=1000};
CosmosClient cosmosclient = new CosmosClient(connStr, options);
Container container = cosmosclient.GetContainer("CoachAPI", "Vessels");
var allItemsQuery = container.GetItemQueryIterator<string>("SELECT * FROM c.id");
List<Task> concurrentDeleteTasks = new List<Task>();
while (allItemsQuery.HasMoreResults)
{
foreach (var item in await allItemsQuery.ReadNextAsync())
{
concurrentDeleteTasks.Add(container.DeleteItemAsync<string>(item, new PartitionKey("id")));
}
}
await Task.WhenAll(concurrentDeleteTasks.Take(3));
抛出以下错误: '响应状态码不表示成功:NotFound(404);子状态:0;
【问题讨论】:
标签: azure-cosmosdb azure-cosmosdb-sqlapi