Azure Cosmos DB for Mongo DB

Azure Cosmos DB is a database platform that supports different NoSQL database engines. I have always preferred platforms that bring different products under one roof. It is much easier for users to complete their jobs rather than jump from product to product.

Mongo DB is one of the NoSQL database engines available in Azure Cosmos DB. By bringing your Mongo DB in Cosmos DB platform, you gain access to numerous potential integrations with various Azure services. Microsoft offers over 200 services and products. Imagine what you can create with your data and all the available services that Azure offers you.

For example, you can utilize Azure AI Foundry for all your AI needs. Connecting your MongoDB databases in Azure Cosmos DB to Azure AI Foundry is straightforward, allowing you to generate embeddings, work with applications using the RAG pattern, and access various new features of Azure AI Foundry. By using Azure Cosmos DB as your MongoDB database, you create numerous opportunities for yourself and your application.

Your application is like your baby; you want it to succeed! You need it to be prepared for upcoming challenges and opportunities. That’s why you require a database service that can easily integrate with other services and scale up or down as needed. Azure Cosmos DB offers an auto-scaling option. If your application experiences low traffic during the night, your MongoDB resources can automatically scale down, helping you save money when your application is not busy.

Azure Cosmos DB for Mongo DB has different server sizes, storage is billed seperately. Following chart shows you the pricing comparision between Atlas Cloud Platform and Azure Cosmos DB platform.

Pricing Comparison

There are couple of tools available to migrate your Mongo DB workloads to Azure Cosmos DB. The first one is an Azure Data Studio extension called Azure Cosmos DB Migration for Mongo DB. This useful extension allows you to conduct an end-to-end assessment of your workload, helping you identify the necessary actions to migrate your workloads to vCore-based Azure Cosmos DB for MongoDB. If the assessment yields favorable results, you can proceed to migrate databases or collections to Azure Cosmos DB. Microsoft announced that Azure Data Studio retirement, Migration tool will be supported until it moves to Vscode as an extension.

The second option is the Azure Cosmos DB Migration Tool. This is an open-source and highly flexible tool designed to migrate MongoDB and various other data sources to Azure Cosmos DB. Unlike the other migration tool, it does not offer an assessment feature, so it is essential to verify that there are no compatibility issues before migrating your workload.

The third option is to use the native MongoDB tools. You can utilize the mongoexport and mongoimport commands for exporting and importing data to Azure Cosmos DB for MongoDB.

Following command exports the selected collection data into given name json file. You need to run these from the terminal. mongoimport tool works great for ingesting small JSON files.

mongoexport --host <hostname><:port>
--username <username>
--password <password>
--db <database name>
--collection <collection name>
--out <filename.json>

If you like to control what should be exported from a collection, you can use the query parameter.

--query '{"age": {"$gte": 30} }'

You can export data from Azure Cosmos DB for MongoDB Vcore with the following parameters.

mongoexport --uri <connection string>
--db <database name>
--collection <collection name>
--query '{"age": {"$gte": 30} }'
--out <filename.json>

When the data is ready in a json file, you can use the mongoimport command to import data into the Azure Cosmos DB for MongoDB vCore

mongoimport --file <filename.json>
--type json
--db <database name>
--collection <collection name>
--ssl
--uri <connection string>

Leave a Reply

Your email address will not be published. Required fields are marked *