Share via


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