Questions about the differences between Azure DocumentDB and Azure Table Storage are asked quite often at Stack Overflow and various other Q&A sites. This short article will explain the differences and describe why you might want to choose one over the other.

If you’re looking for a comparison between Azure DocumentDB and Azure SQL Database, you can find it here.

Executive Summary

If you’re in a hurry and just want the conclusion, here it is: Azure DocumentDB is more capable than Azure Table Storage, but is also more expensive. You can save a significant amount of money by choosing Table Storage if it meets your needs. Read on to learn more.

Azure Table Storage

Azure Table Storage is a distributed, high performance NoSQL key-value store.

Benefits:

All commits are automatically replicatied – 3 times in one geographic region, and 3 times in another. This ensures that data will still be available even if an entire datacenter goes dark.

Strong consistency – once data has been added or updated, all future accesses of that data will see the updated version. In contrast, some other NoSQL data stores only offer eventual consistency. In these cases, reads are not guaranteed to see the most recent updates.

Flexible schema – like other NoSQL data stores, Azure Tables does not require a fixed schema to be defined up front.

Can easily scale to store billions of entities while still providing good performance.

Affordable – prices range from 4.5 to 12 cents per gigabyte.

Limitations:

Each table contains only two indexed columns: a partition key and a row key. This means that you can only run queries based on these keys. You can’t index any columns or properties of the rows you insert, and so can’t run queries against them. This isn’t always a deal breaker – it just means that Table Storage will be a good fit for some use cases, but not for others.

Tutorial:

For an up-to-date look at Table Storage in action, check out Microsoft’s Azure Table Storage Tutorial for .NET.

Azure DocumentDB

DocumentDB is a relatively new addition to the Azure family. It was introduced in August of 2014. It is a distributed document database. It can be used in scenarios where other document stores such as MongoDB would be a good fit.

Benefits:

Documents are stored in JSON format, which makes them very easy to work with in a wide variety of programming languages.

Offers a range of consistency levels, ranging from strong consistency to eventual consistency. This makes it possible to adjust consistency to suit your application’s needs.

MongoDB protocol support: Applications designed to be used with MongoDB can be connected to DocumentDB without any changes.

SQL Queries: Although DocumentDB is a non-relational data store, it supports SQL, so developers already familiar with database such as MySQL, Postgres, and SQL Server can get up and running quickly. Since DocumentDB is non-relational, some SQL features such as joins work differently than developers might expect.

Limitations:

Price: at 25 cents per gigabyte, it is more than double the cost of Azure Tables’ most expensive rate.

Scaling: While DocumentDB can scale to hold a large amount of data, document collections that will need to scale easily have to be created as partitioned collections from the beginning.

Conclusion

It comes down to choosing the data store that best meets your needs.

On Azure, Table Storage is inexpensive and easy to scale.

DocumentDB is more expensive and somewhat more difficult to scale, but offers a much richer feature set and query language.

Also worth mentioning is the Azure SQL Database. With excellent SQL Server compatibility, it offers the ability to easily migrate existing enterprise applications to the cloud. It’s more expensive and more difficult to scale than either Table Storage or DocumentDB, but offers rock solid reliability along with the full power of SQL and a relational database.