Have have following partion id on my container: /vesselId
I am trying to add a collection of this object:
public class CoachVessel
{
[JsonProperty("id")]
public string vesselId { get; set; }
[JsonProperty("imo")]
public long Imo { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
}
This is my code to bulk insert the documents:
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);
I get following error that does not provide much information?
Microsoft.Azure.Cosmos.CosmosException: 'Response status code does not indicate success: BadRequest (400); Substatus: 1001; ActivityId: ; Reason: ();'
Any pointers to what causes this? This is my settings:
I have same problem when deleting documents:
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));
Throws following error: 'Response status code does not indicate success: NotFound (404); Substatus: 0;