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
Bulk Insertion of records in Cosmos DB getting failed
Debashis Jena
71
Reputation points
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.