Bulk Insertion of records in Cosmos DB getting failed

Debashis Jena 71 Reputation points
2024-02-02T13:15:14.6466667+00:00

With our Web API application we are trying to upload 3500 records to cosmos DB. As regular For loop is taking much more time for uploading all the records, we are trying to upload using bulk execution. For that we have used Task.WhenAll multithreading mechanism. However it is not able to upload all the records & some of the records are not getting processed. So it seems like this mechanism is not Reliable.
Please provide how we can resolve this issue.
Please suggest if there is any other mechanisms to insert large number of records into Cosmos DB.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,803 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,799 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,340 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 72,996 Reputation points
    2024-02-02T17:42:33.38+00:00

    you should not create 3500 threads. use the Parallel library, and set max concurrent threads: https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.parallel?view=net-8.0


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.