Shaun Xu

The Sheep-Pen of the Shaun



Shaun, the author of this blog is a semi-geek, clumsy developer, passionate speaker and incapable architect with about 10 years’ experience in .NET and JavaScript. He hopes to prove that software development is art rather than manufacturing. He's into cloud computing platform and technologies (Windows Azure, Amazon and Aliyun) and right now, Shaun is being attracted by JavaScript (Angular.js and Node.js) and he likes it.

Shaun is working at Worktile Inc. as the chief architect for overall design and develop worktile, a web-based collaboration and task management tool, and lesschat, a real-time communication aggregation tool.


My Stats

  • Posts - 122
  • Comments - 622
  • Trackbacks - 0

Tag Cloud

Recent Comments

Recent Posts

Article Categories


Post Categories



What's DocumentDB

DocumentDB is a fully-managed, scalable, NoSQL document database service in Microsoft Azure. It provides rich query and indexing capabilities over a schema-free JSON data model. It also provides configurable and reliable performance, native JavaScript transactional processing, and is built for the cloud with elastic scale.

DocumentDB was announced on 22nd October as a preview feature. User can provision through the new azure portal.

If you are not familiar or this is the first time you hear about DocumentDB, I'd like suggest you to read my previous post. I also recommend you to read some documents about it in Microsoft Azure website.


What's "My DocumentDB" & Why I Created It

"My DocumentDB" is a web-based DocumentDB Management tool I had just created. The reason I created is because, in azure portal there's very few features for us to manage a DocumentDB.

As you can see it's easy to create or delete a DocumentDB account in azure portal as below.


And inside an existing DocumentDB account there are many monitors and status reports. We can also create and delete a databases, and view the collections' basic information under a certain database.


But that's all. I found that we cannot create or delete a collection, cannot create, update or delete a document under a collection. This makes me a little bit hard to use when I'm working with DocumentDB. Hence this is the reason why I created "My DocumentDB". And in order to make it cross-platform and easy to use, I decided to create a web-based tool rather than a client application.


"My DocumentDB" Features (Currently)

Currently there are three features in "My DocumentDB":

- Database Management: List, create and delete a database.

- Collection Management: List, create and delete a collection under a certain database.

- Document Management: List, create, update and delete a document under a certain collection.


Below is the home page of "My DocumentDB". On the top right corner we need to specify the host and key we want to connect.


The host and key can be copied from the DocumentDB details page from azure portal as below.


After specified the host and key, press the "Connect" button. Then there will be two menu items appeared as below. The "Explorer" menu navigates us to the main management pages. The "Console" page content is still under developed.


When clicked "Connect", this application will NOT connect to your DocumentDB. It just stored the credentials inside local JavaScript variants. If it's incorrect you will got error message when clicked "Explorer" menu.

Ref the credentials and potential security risks please refer to the security section later in this post.

Click "Explorer" menu will list all databases in the DocumentDB account. And we can create and delete a database by clicking the related button.


Note that when we are going to delete a database, it asked us to re-input the database ID for double verification.


Click a database ID will list all its collections. In this page we can create and delete collections as well. Similarly, when deleting a collection we also need to re-input the ID.


Click a document ID will list all its documents. In this page the document ID and resource ID will be displayed by default. If you want to view the content of the document you can click the arrow icon in front of each row as below.


We can create, edit and delete a document from this page as well. When deleting a document we also need to re-input its ID. When create or edit a document we need to provide the ID as well as the content. Since the document is a JSON, in the popup window we need to specify in JSON format. Currently we only support raw JSON string in the "Raw" tab. In the future we might introduce a JSON editor.

imageThe ID property was specified from the separated input box in this window so we don't need to put it into the content box. And if we specified ID in both places the one in the content will be replaced. For example, I specified ID in top input box with value "123" and in the content input box you specified as below.

   1: {
   2:   "id": "456",
   3: }

Then the document inserted into DocumentDB will be

   1: {
   2:   "id": "123"
   3: }

Below is the new document I had just created.



  • Architecture

  • Below is a brief architecture diagram of this project. Basically all request will be sent from "My DocumentDB" web pages to backend "My DocumentDB" API, then sent to Azure DocumentDB REST service.

  • image


Source Code & Deployment

You can find the source code of "My DocumentDB" on GitHub. And Currently there are three ways to use "My DocumentDB".

The first one is to use the live demo I deployed in Azure Website located at North Europe data center. This is the most easy way. But it might introduce connection legacy and cost if your DocumentDB was created in other data centers.

The second way is to deploy "My DocumentDB" in your Azure account. This is simple, too. Since it's designed for Azure, what you need to do is to download the source code from GitHub and deploy to any Azure Website you have.

The last choice, you can deploy "My DocumentDB" on premise. Similar as the previous one, download the source code to you desktop, make sure you have Node.js installed and execute the command as below. Since "My DocumentDB" is hosted by Node.js, you can run it under Windows, Linux and Mac.

   1: node.exe server.js --port=[port number] [--debug]

When deploying "My DocumentDB" locally you need to ensure the Internet connectivity without proxy. Currently we don't support local deployment under a proxy Internet connectivity environment.



Security Risks

I created "My DocumentDB" and worked in spare time so that I didn't pay more effort in security consideration. There might be some risks when you are using it please be aware. And since "My DocumentDB" was released with MIT license I will NOT provide any warranties.

No SSL connection.

Currently "My DocumentDB" will be hosted with HTTP instead of HTTPS. This means the data between your browser and "My DocumentDB" server can be seen by others. But the connection to Azure DocumentDB is HTTPS. You can change the source code to enable HTTPS if you are going to deploy to your own azure service or local.

Wildcard SSL Certificate

Azure Website support wildcard certificate for its all sites. This means you can simply use for security connection on the live demo. But if you need more security request I'd like you deploy to your own azure account with your certificate.

Credentials will be stored in local JavaScript variants.

Currently the DocumentDB host and key will be stored in the local JavaScript variants and passed to "My DocumentDB" service through HTTP headers. This means if you forgot to disconnect others would be able to see your credentials by opening the debug mode of your browser.


Based on these risks I personally recommend

1. Click "Disconnect" button when you don't use it, or when you need to leave for a moment.

2. Local deployment provides better security boundary than using live demo since all sensitive data are stored in your machine, and the connection to Azure DocumentDB is HTTPS.



As I mentioned below this is the first version of "My DocumentDB". Based on your feedback and usage there might be more features in pipeline I'm going to implement. Below are some of them in my mind. Hopefully I have passion and energy to work them out.

1. Console

In the console page user can execute DocumentDB query console against database, collection or document. Developers can try their query and check the result before implementation.

2. JSON editor

Currently user has to use plaint JSON string when create or edit a document. In the future I will add a JSON designer in document edit window.

3. Paging

Currently I didn't specify any paging options in requests. But if there are many documents in a collection we'd better let users specify how many items per page they like.

4. More to manage

We only support databases, collections and documents management, but there are many more things in DocumentDB such as users, stored procedures, triggers and attachments, etc. They should be able to be managed as well in the future.


Feedbacks & Issues

I encourage everyone to try "My DocumentDB", either from the live demo, or self host on azure or local. If you have any questions or issues please feel free to contact in the GitHub page.


Hope this helps,


All documents and related graphics, codes are provided "AS IS" without warranty of any kind.
Copyright © Shaun Ziyan Xu. This work is licensed under the Creative Commons License.