Azure DocumentDB is a NoSQL document database-as-a-Service from Microsoft Azure is designed for saving, retrieving and managing each record in an internal structure of fields (semi-structured data, documents or keys). DocumentDB is a schema free JSON document database and also support JavaScript. DocumentDB includes built-in high availability, offers predictable performance and supports elastic scale-out. DocumentDB has some exciting features.
- Tunable, high performance.
- Multi document transactions.
- Query over schema free JSON.
- Automatic Indexing.
- Easy to learn query grammar.
- Low-latency access around the globe.
- Rich SQL queries over schema-free JSON storage.
- Server side execution of the Application defined JavaScript as stored procedures and triggers.
- JavaScript language integration for multi-document transactions.
- Tunable consistency levels for optimal Application performance.
- Standard JSON storage with RESTful HTTP interfaces.
Let’s understand it by performing something practical on the portal. Enter your credentials and login to Azure portal. Go to New, select Storage and click See All because it seems there is no DocumentDB in Featured Apps.
Select NoSQL and click it. Here, I need to create Document Account.
Give a name to your account and select API for it. There are two options for selecting API DocumentDB and MongoDB. I’ll discuss MongoDB in my further articles. All steps are same and are related to the previous articles. Click to create DocumentDB Account.
Under DocumentDB account, I have to create a Collection. It is a logical container for the physical partitions. A collection is like a container for JSON documents and JavaScript Application logic. Click Add Collection to add a new one.
For a collection, give a name to your collection and its storage capacity to handle collection is up to 10 TB and set a storage capacity for it. Now, there is a Partition key, which is a JSON property within your documents. Partition key is an element within your document. Give a database name to it and click OK button to create a Collection.
Thus, my collection is ready now.
Go to Document Explorer, where we can create and upload our documents under our Collection.
Click Create and you will see a JSON format script with ID and People (partion). You can upload JSON script as well. I’ve given an Id and some data in People Partition. Click Save to save this script.
Now, go to Query Explorer and run a query.
The query will be executed successfully and produces the expected result.