CosmosDB Driver
Table of Contents
You can manage your CosmosDB migrations by using the Mongock drivers for MongoDB
# Introduction
Azure Cosmos DB provides multiple APIs to connect to it. One of them it's the API for MongoDB, which makes it easy to use Cosmos DB as if it were a MongoDB database.
You can leverage your MongoDB experience and continue to use your favorite MongoDB drivers, SDKs, and tools by pointing your application to the API for MongoDB account's connection string.
# Getting started
You can use Mongock to manage your Cosmos DB migrations in the same way you would do with MongoDB, using one of the drivers Mongock provides for MongoDB. You can see how to use it in our MongoDB driver section
# Important notes
# Sharding the Mongock ChangeLog collection
If you want to shard the Mongock changeLog collection, you need to use the key executionId
as shard key. This is due to the fact that the executionId
is the prefix of the Mongock's compound index and the MongoDB official documentation states:
...The index can be an index on the shard key or a compound index where the shard key is a prefix of the index.
You can find more information about shard keys and prefixes
# Transactions
Although MongoDB does support Multi-document transactions(in a single or multiple, and sharded collections), they are not supported across collections or in sharded collections in Cosmos DB version 4.0 (non-vCore).
# Resources
You can find more information about Cosmos DB with MongoDB API and Java, here: