Creating, Configuring and Querying DocumentDB in Azure

DocumentDB is a NOSQL JSON based data store available in MS Azure. In this post we cover how to create a document database followed by a Collection and then we store documents into these collection. Once done we will querying the files using the query windows available directly within the portal.

First we visit the azure portal and Click new followed by

Search for and click DocumentDB

On the next blade press CREATE

On the below screen we need to give our DocumentDB account a unique name and specify the resource group it belongs to. This step can take a few minutes to complete.

Once the document database account is created we need to create a new database into which we will put our data. Click Add database in the below screen

Enter a name for the database and then press OK

Next we create for the collection as show below, click the database name from the list of database shown below within the DocumentDB account.

Click add Collection as shown below

Enter a name for the collection and then choose an appropriate pricing tier and indexing policy

The indexing policy determine the storage and performance characteristics of the collection, below are the two different options. When Done press OK on the above screen.

With collection ready we are now going to upload some JSON Documents into the collection. JSON like XML is a format that allows use to store data that isn’t strictly structured like row and columns in a table. This can be done from the Upload Button on the collections screen as shown below.

Click the upload document button

Then click the folder ellipse and select the JSON files to be uploaded

You can also manually create a file into the DocumentDB repository as shown below , click Create Document.

Then enter the JSON data into the file, every unique JSON file needs a id which can be used to reference it, much like the PK of a table.

Once the files are saved you can query files that meet your search criteria by querying it directly within the management portal as shown below

Enter your query in the query windows and press the Run Query button, in the next post we will cover some common types of queries that can be executed.

And now you have a DocumentDb in which JSON can be queried.