Recently, our client has been planning to use Azure platform and one of the most important factor is to migrate their data from MongoDB Atlas into Azure Cosmos DB. In this article, I would like to summary some necessary steps to migrate data from MongoDB.


Before we start migration process, it requires us to create an Azure Cosmos DB account.

Step 1

  • Login to Azure Portal and go to Resource Group. I have a Resource Group already named ad dungdinh
  • Click Add Resource and then search Azure Cosmos DB and click on Create
  • The screen Create Azure Cosmos DB Account appears
    • Basic configuration
      • Resource Group : dungdinh
      • Account Name: ddcosmosdbdemo
      • API: Azure Cosmos DB for MongoDB API
  • Network Configuration: this step requires us to create a virtual network for Cosmos DB
  • Click Review + Create

Now, the Azure Cosmos DB for document type is ready to use

Step 2

Download and install Studio 3T for MongoDb tool. I use this tool to connect to both Azure Cosmos DB and MongoDB Atlas

Step 3

  • Connect to Azure Cosmos DB with Studio 3T
  • Click on Connection String and copy the PRIMARY CONNECTION STRING
  • Open Studio 3T and add new connection
    • From URI: paste the connection string copied above
  • Click OK and then connect to Azure Cosmos DB
  • Connect to MongoDB Atlas
    • MongoDB Atlas is the cloud platform of MongoDB and I have a database named Cities and a collection named zipcodes in this database.
    • Click on Connection and get Connection String
  • Create a new connection in Studio 3T, paste the URI copied above

Now, I can connect to both Azure and MongoDB Atlas

Step 4

In this step, I import the zipcodes collection in Cities database from MongoDB Atlas to Azure Cosmos

Before importing data, I create a database named Cities in Azure Cosmos DB created.

  • On Studio 3T, expand Cities database and right-click on zipcodes collection then select Export Collection
  • Select JSON option, click Next
  • Select JSON – mongodb shell
  • On the connection to Azure, expand Cities database and then right-click on Collection folder. Select Import Collection, then Next
  • Browser to the JSON file exported then Next

Step 5

Now, the zipcodes collection is imported into Azure Cosmos DB successfully. Go back to Azure Portal and then refresh the Cities database to see result.


In this article, I would like to instruction how to import data from MongoDB Atlas to Azure Cosmos DB manually with using the Studio tool. You can definitely use the command line such mongodbimport to execute this task. In case you have MongoDB in Azure Virtual Machine, you can also use Azure Database Migration Service to migrate data. I will provide the instruction in next article to work with this service.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.