In Azure DocumentDB, DocumentClient.CreateDocumentQuery doesn’t exists!

This is a quick help for you out there who are developing against Azure DocumentDB in .NET.

Maybe you read the Getting Started guide or you found that line of code somewhere else.

var families = client.CreateDocumentQuery(documentCollection.DocumentsLink,

“SELECT * ” +

“FROM Families f ” +

“WHERE = \”AndersenFamily\””);

Then you try this at home only not to find the said CreateDocumentQuery on the class Microsoft.Azure.Documents.Client.DocumentClient.

No it isn’t there. It isn’t because this is a preview service and the doc is out-of-date. It is a good old Linq / extension methods trick.

You need to add the line

using Microsoft.Azure.Documents.Linq; 

at the beginning of your code. This way the code snippet above will actually pick up the extension methods class Microsoft.Azure.Documents.Linq.DocumentQueryable.

Managing Databases and Collections with DocumentDB Studio

I released the first Beta version of DocumentDB Studio.

DocumentDB Studio is to Azure DocumentDB what SQL Management Studio is to SQL Server and SQL Azure: a one-stop shop to manage and interact with your DocumentDB.

I posted an installation guide of the application (very simple).

In this post I want to walk you through:

  • How to connect to a DocumentDB account
  • How to create / delete databases in an account
  • How to create / delete collections within an account

Account keys

You need an Azure DocumentDB account to start using DocumentDB Studio.

See my article Creating an Azure DocumentDB account for an easy how-to. I’ll assume you created such an account.

Now let’s go and retrieve a ??? key.

  1. Go to the Azure Preview Portal:
  2. On the left hand side, select the BROWSE button and then DocumentDB Accounts
  3. You’ll be presented with the list of DocumentDB accounts you own ; select the one you want to work with.
  4. You will be presented with the account blade. Click the keys button.
  5. In the keys blade, click the copy button next to the secondary key

DocumentDB accounts come with a primary and secondary. Personally, I always like to give applications the secondary key while keeping the primary for myself. But it’s a personal choice, you can use the primary key as well.

Connect to an Account

Now that we have an account and an account key, let’s connect to it in Azure DocumentDB Studio.

  1. Click the Connect button
  2. In the ID textbox, type the ID (or name) of your Database account, without the entire URL.
  3. In the Authorization Key, paste the secondary key you copied in the previous section.

You just connected Azure DocumentDB Studio to your database account.

Note that in the folder where you copied the binaries of the solution, a new file has been added: Studio.xml. This file now contains the ID and authorization key of your database account. This is how your connection persists between instances of the studio.

Creating a database

Now, let’s create a database.

We’ll expand the account tree branch and discover the databases and media. Let’s select the databases.

Everywhere in the resource tree, resources are lazy loaded or loaded on demand. In the case of databases, until you select the tree node, databases aren’t loaded. Once you select it they are asynchronously loaded.

In our case, there are no databases yet, so let’s create one by clicking on the New Database button in the toolbar.

This pops up a dialog to query the ID (or name) of the database. Let’s type MyDB and then click OK.

This creates a MyDB database with no collections.

By opening the MyDB tree node and clicking the Collections sub node the New Collection button in the toolbar becomes enabled.

Let’s click it to create a collection. Very similar experience to creating a database.

Now if we want to delete the collection we just created, we need to select the collection in the tree view to enable the Remove Collection button in the toolbar.

Similarly, to delete the Database we created, we select the Database in the treeview.

So that was it for the management of databases and collection!

Installing DocumentDB Studio

As I announced yesterday, I released the first Beta version of DocumentDB Studio.

DocumentDB Studio is to Azure DocumentDB what SQL Management Studio is to SQL Server and SQL Azure: a one-stop shop to manage and interact with your DocumentDB.

In this blog post I’ll simply walk you through the installation process.


Simply go to and follow the big download link on the main page.

The current release is version but by the time you read this it might be higher.

The current deployment package is a zip file. I wanted to do a Click Once deployment but with a self-signing certificate, Windows 8 seems to refuse to execute it (for security reason), so I fell back on a local install. If you know a way around it, please drop me a line.

There are no install file, simply unzip the file somewhere, e.g. on your desktop. Execute StudioDocDB.exe:

If you run Windows 8, it might complain about the fact it doesn’t recognize the application. In that case, click More Info:

Then click Run anyway

I’ll try to smooth those things out in future release!

After those steps you should see the app!

Creating an Azure DocumentDB account

In this post I will guide you on how to create an Azure DocumentDB account.

If you remember the Azure DocumentDB resource model, the entire resource model is rooted at the Database account:

So, step by step:

  1. Go to the preview portal:
  2. Click the NEW button at the bottom left
  3. Select DocumentDB (scroll if you have to)
  4. In ID, enter the name of your Database account. Here I’m going to use demovince.
  5. Click Create at the bottom of the blade

That’s it, you’re done!

It will take up to 10 minutes to provision the account but this is all automatic, you just sit down and wait.

DocumentDB Studio first (beta) release

I finally done a first release of my latest project, DocumentDB Studio!

DocumentDB Studio is to Azure DocumentDB what SQL Management Studio is to SQL Server and SQL Azure: a one-stop shop to manage and interact with your DocumentDB.

The first release is quite minimalist and only let you:

  • Connect to different DocumentDB accounts
  • Create / delete databases within those accounts
  • Create / delete collections within databases

The next release should include ability to perform document insertion and queries.

I did start this project in order to palliate the lack of tool for Azure DocumentDB. That product is very interesting but I feel that having to code in order to toy with it is too high an entry barrier.

Document Studio aims at lowering the entry barrier and let potential users play around with the product.

Stay tune for more details on that project!

Profile of MSN Health and Fitness on Azure DocumentDB

We already know that Azure DocumentDB was used in the back-end of OneNote. Last week Microsoft released another nice case study: the user profiles for MSN portal.

The requirements for the solution were:

  1. Scale requirements to support +425M unique MSN users with +100M direct authenticated users. Initial capacity requirements for 20TB of document storage.
  2. Under 15ms write latency and single digit read latencies for 99% requests.
  3. Authorization scopes across the same underlying data.
  4. Schema free storage with rich query and transaction support.
  5. Data model extensions to support the diverse set of verticals schemas.
  6. Hadoop based analytics on top of the data.
  7. Available globally to serve all MSN markets and users.

Here we see the typical requirements leading to a NoSQL solution:

  • Data volume
  • Read / Write performance
  • Schema free

On top of those typical requirements, Azure DocumentDB offers the atypical rich querying without pre-configuration.

Look at this case study. You might recognize some pattern in a solution you are working on. If that is so, you might want to look into Azure DocumentsDB.

NoSQL implementation concepts

While familiarizing ourselves with Microsoft new DocumentDB, a solid foundation on NoSQL doesn’t hurt.

A few years ago, I saw a couple of great presentations on Channel9 (from a TechED if I am not mistaken) about Azure Storage. The presenters went into how partitioning works, how requests are routed, how consistency is ensure, how resiliency (in case of node failure) is insured, etc. . Those were quite specific to Azure Blob & Table storage.

Recently, I came across Ricky Ho‘s excellent NoSQL primer: NOSQL Patterns. This article has two main advantages:

  • It is relatively generic (it isn’t tied to a specific implementation of NoSQL product)
  • It is relatively short (compare to a one hour Channel9 presentation)

This conceptual overview gives you an excellent background to better understand the mechanism behind Azure DocumentDB and its design tradeoffs.

Ricky goes into:

  • Topology: how are physical and virtual nodes laid out
  • Partitioning: how is data partitioned & replicated over many virtual nodes
  • Dynamic Membership: how is data mapped to different partitions as nodes join and leave the topology
  • Consistency: how is the database exposing a consistent view to a consumer while data is replicated and moving around on many distributed nodes
  • Replication algorithms

It is especially interesting while working with Azure DocumentDB since that product offers a lot of configurable tradeoffs (e.g. in terms of consistency policy, index building, etc.).