Share via


Azure Cosmos DB: Migration from SQL to Cosmos DB

In a previous post we talked about Azure Cosmos DB. In this one we will talk about migration methods to Cosmos DB and more specific we will see an example with SQL Server data.

Prerequisites

  • Download the Azure Document DB migration tool from here
    • (DocumentDB Data Migration Tool gives the ability to migrate data from different sources to Cosmos DB.)
  • Download the demo database AdventureWorks2017 database from GitHub.

Important Notice : For this demo we use the same Cosmos DB database from the previous post "Let’s talk about Azure Cosmos DB"

Migration from SQL DB

Ιn the next steps we will see how it evolves the DocumentDB Data Migration tool from a SQL Server database to Cosmos DB document.

Source Information

Select from the drop-down menu [SQL], Type database connection string and click Verify

Important Notice : Don’t use the examples connection string, it is not compliant with GDPR.

In the next step you can Enter Query or Select an existing query for import.

Target Information

At the Target information form, we select a path to export the data, e.g DocumentDB – Sequential record import (partitioned collection), add Cosmos DB Connection String (From the Azure Portal, Settings – Keys – {PRIMARY CONNECTION STRING}). Type Collection Name , e.g Items. Type Partition Key, e.g /Id and finally set the Collection Throughput, e.g 100

Advanced

In the Advanced configuration we select a path where the Error Log File is saved and we choose the Detailed Error Information.

Summary

In the summary page we confirm all the import settings, e.g Source (SQL) – Connection String, Query, etc. Target (DocumentDB – Sequential record import (partitioned collection)), Connection String, Collection, Partition Key, etc. If summary look fine, then click [Import] to start process.

Results

Finally, in the Import results page we can see that 18508 records transferred to Azure Cosmos DB (ToDoList) in 0:02:28:07 minutes.

Conclusion

For each new product or service, Microsoft provides users with all the necessary tools. So in the Cosmos DB (ex Document DB) service announce a very useful tool called {DocumentDB Data Migration Tool}, with this tool we can migrate from existing data sources to Cosmos DB. In this post, we take a sneak peek from SQL Server to Cosmos DB.

Microsoft Documents

Technet Documents