We all work with data somewhere or the other, and migrating it from one place to another sounds like a hassle in itself.
In this blog post, we will see how easily we can migrate any of our data into Cosmos DB. To migrate your data from any source to Cosmos DB, you can use Data Migration Tool which is an open source utility available on Microsoft Download Center.
To download this tool from the Microsoft Download center, go the link below:Microsoft Download Center
Also, you can refer to the Azure documentation which provides the link to the download center. Another good thing with this being an open-source project is that its source code is available on GitHub.
To access the source code for this project on Github, go to the link below:Azure/azure-documentdb-datamigrationtool
Azure DocumentDB Data Migration Tool. Contribute to Azure/azure-documentdb-datamigrationtool development by creating an…github.com
This contains all the supported data sources from where you can import the data inside your CosmosDB project. Some of the supported sources for importing your data from are:
- SQL server
- Mongo DB
- Azure Table Storage
- CSV files
- Flash files
- JSON data
When we import the data from JSON files, it is simple to import them as they are but to import the data from relational databases, it is not very easy as it needs to be tweaked.
By this transforming, we mean that the normalized data in SQL server has to match up the de-normalized way of the data in the JSON.
But how do we import this data? Let us take a look at that.
To start the import of data from a SQL server into Cosmos DB, we take a sample SQL data from AdventureWorks.
What is AdventureWorks? In simple terms, a sample database for SQL server. Now inside AdventureWorks, pick up any of the views. Views? Another terminology!
Views are mainly a combination of related table entities. Open any of the views from the database and when you look at the data, each of the data is derived from different tables of that view. Select the query and using the id of the data, which is actually a string that will be used as the data import identifier into the data migration tool.
Inside the data migration tool, you then define connection strings, indexing policies etc. to connect the data from your sample SQL server to the Data migration Tool which eventually will import all the data into your Cosmos DB account provided, you have put in the URI, connection string and other required details of your Cosmos DB account.
This article is just a brief introduction of Data Migration Tool. However, installing the data migration tool and getting it into Cosmos DB using a sample SQL server is a task in itself. In the next blog post, we will see the installation of Data migration tool and import of data from SQL server into Cosmos DB.
In this blog post, we started off by discussing the role of migration of data from one tool to another, followed by the access to data migration tool, an open source utility which allows us to import data from many data sources into Cosmos DB. We also saw how when getting to bringing in data from a SQL server, AdventureWorks proves to be very helpful by the provision of sample SQL server.