Azure CosmosDB (Mongo) 3.6 with .NET MongoDB.Driver 2.10

When creating an Azure Cosmos DB with Azure Cosmos DB for MongoDB API V3.6 and copy the ConnectionString to your application using MongoDB.Driver (in my case 2.10) it's possible that you will see this Exception:

MongoDB.Driver.MongoCommandException: 'Command insert failed: Retryable writes are not supported. Please disable retryable writes by specifying "retrywrites=false" in the connection string or an equivalent driver specific config..'

If you use Azure Cosmos DB for MongoDB API V3.2 this error won't appear.
To avoid this Exception, you have to append &retrywrites=false to your ConnectionString.

Quote from https://docs.mongodb.com/manual/core/retryable-writes/ :
The official MongoDB 4.2-compatible drivers enable Retryable Writes by default. Applications upgrading to the 4.2-compatible drivers that require retryable writes may omit the retryWrites=true option. Applications upgrading to the 4.2-compatible drivers that require disabling retryable writes must include retryWrites=false in the connection string."

Sources:
https://docs.mongodb.com/manual/core/retryable-writes/
https://www.mongodb.com/blog/post/transactions-background-part-6-retryable-writes


comments powered by Disqus