This issue is closed Hangfire has fixed this issue. Thank you.
Hangfire is not working for CosmosDB after migrating from MongoDB giving error: A bulk write operation resulted in one or more errors. WriteErrors: [ { Category : "DuplicateKey", Code : 11000, Message : "E11000 duplicate key error collection: Hangfire
We were using MongoDb in our project and Hangfire was working perfectly fine over there but after we have shifted to CosmosDb Hangfire has stopped working, we are using MongoClient only to connect to CosmosDB by passing CosmosDB connection string to MongoClient everything is fine with this MongoClient object but Hangfire is not working with this. It is creating Hangfire default collections into the CosmosDB and when we are trying to manually execute any of the jobs from Hangfire dashboard it gives us this error:
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. MongoDB.Driver.MongoBulkWriteException`1[MongoDB.Bson.BsonDocument]: A bulk write operation resulted in one or more errors. WriteErrors: [ { Category : "DuplicateKey", Code : 11000, Message : "E11000 duplicate key error collection: bomHangfire2.core.hangfire.jobGraph. Failed _id or unique index constraint." } ]. at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IClientSessionHandle session, IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken) at MongoDB.Driver.MongoCollectionImpl`1.<>c__DisplayClass30_0.
Developer technologies | ASP.NET | ASP.NET Core
Azure Cosmos DB
2 answers
Sort by: Most helpful
-
-
Oury Ba-MSFT 21,121 Reputation points Microsoft Employee Moderator2023-10-06T15:39:02.79+00:00 @Murtuza Pithawala Thank you for reaching out.
Problem:
Hangfire is not working for CosmosDB after migrating from MongoDB giving error: A bulk write operation resulted in one or more errors. WriteErrors: [ { Category : "DuplicateKey", Code : 11000, Message : "E11000 duplicate key error collection: Hangfire
Solution:
Customer contacted Hangfire who fixed the issue.
Regards,
Oury