Bulk insert Azure Cosmos DB

Viewed 1677

I can found some samples stating following should be bulk inserts:

var options = new CosmosClientOptions() { AllowBulkExecution = true, MaxRetryAttemptsOnRateLimitedRequests = 1000 };
Client = new CosmosClient(ConnStr, options);

public async Task AddVesselsFromJSON(List<JObject> vessels)
{
    List<Task> concurrentTasks = new List<Task>();
    foreach (var vessel in vessels)
    {
        concurrentTasks.Add(VesselContainer.UpsertItemAsync(vessel));
    }
    await Task.WhenAll(concurrentTasks);
}

I am running the code on an Azure Function (App Plan) with 10 instances. However I can see it is only around 4 inserts pr seconds. With SQL bulk insert I can do thousands a second. It does not seem like above is bulk inserting have I missed something?

1 Answers

Check your Cosmos DB Scale settings. I ran into the same issue. When you change from manual to autoscale, the default max RUs are set to 4000. Change it to an appropriate number based on your scenario. You can use https://cosmos.azure.com/capacitycalculator/

enter image description here

Related