The goal of this post is to write a C# sample application to perform basic requests to Azure DocumentDB: Create, Read, Update, Delete and Find documents.
You can find the code on my github: https://github.com/softwarejc/documentdb
Relational databases have been the dominant approach to store data for decades and they will probably be used for a very long time. However a lot of modern applications work with JSON, a format that does not fit naturally in a relational system.
NoSQL databases came to solve this problem and to improve the scalability of relational databases. NoSQL also allows working with data that change fast without having to change the database.
There are different types of NoSQL databases:
- Document stores: MongoDB, Azure DocumentDB
- Key/Value stores: Riak
- Column stores: Cassandra
- Big data analytics: HDInsight, Hadoop
The focus of this post is the document store offered by Microsoft: Azure DocumentDB.
You can read more about MongoDB vs DocumentDB here: http://justazure.com/mongodb-vs-azure-documentdb/
Create a DocumentDB in Azure
The creation of a DocumentDB is very straight forward.
Scott Hanselman explains it very good in this video:
You can read the about pricing information here:
How to use DocumentDB with C#
DocumentDB officially supports the following programming languages:
We will be using .NET C# 6.
The first thing that we have to do is to add a Nuget package that will do part of the job for us: Microsoft.Azure.DocumentDB: