Cosmos DB API for MongoDB: Transaction support on multiple collections

MikeZheng-3371 46 Reputation points


We're using the Cosmos DB API for MongoDB. I just wonder how can we do the transactions on multiple collections, what is the best practice?



Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,466 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Oury Ba-MSFT 16,731 Reputation points Microsoft Employee

    Hi @MikeZheng-3371Thank you for posting your question on Microsoft Q&A and for using Azure services.

    From my understanding you are trying to do transactions on multiple collections.
    Multi-document transactions are supported within an unsharded collection in API version 4.0. Multi-document transactions are not supported across collections or in sharded collections in 4.0.
    All drivers that support wire protocol version 4.0 or greater will support Azure Cosmos DB API for MongoDB multi-document transactions.


  2. Oury Ba-MSFT 16,731 Reputation points Microsoft Employee

    *What is the alternative solution? *
    Restructuring the data to be within one collection or implementing the rollback logic on the applications side would be two options.


    0 comments No comments

  3. MikeZheng-3371 46 Reputation points

    Would you please provide an example of implementing the rollback logic on the application side? It is impossible for us to have ONLY one collection in the system.