Quick Guide on Importing Data from SQL Server (or SQL Azure) to Cosmos DB


Sample code here: https://github.com/knethteo/SQLAzuretoCosmosDB

This sample does the following:

  1. Create SQL DB Table.txt That will create the initial database in SQL Server or SQL Azure
  2. The main Program will read the database, parse the data and store them in Cosmos DB

Before you start the program, you will have to do step 1, and edit the app.config:

  • endpoint: Your cosmosDB endpoint
  • primaryKey: Your cosmosDB primary key, you can get this from your Azure Portal's CosmosDB blade
  • connectionString: The connection string to the SQL Database where your original data resides. In the sample App.config, this is referenced to SQL Azure, Microsoft Azure SQL DB
  • database: database name in your CosmosDB
  • collection: Collection name of the CosmosDB database

Comments (0)

Skip to main content
The information in this weblog is provided “AS IS” with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the author’s discretion. All code samples are provided “AS IS” without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The inclusion of any link does not imply endorsement by Microsoft of the linked site.