Azure DocumentDB Limitation

The original document  is here at https://azure.microsoft.com/en-us/documentation/articles/documentdb-limits/, but I am making note to myself here too.  These are worthy to know when you are working DocumentDB and designing the service structure.

  • You can only have up to 5 database accounts by default.
  • You can only have up to 100 database per account.
  • Number of users per account is 500,000.
  • Number of permission per database account is 2,000,000.
  • Attachment storage per database account is 2GB (I ll probably use blob storage and just have uri reference to the location so I m not so worry about this limitation now)
  •  Max request units per second per collection is 2500.
  • Number of stored procedures, triggers and UDFs per collection is 25 each.
  • Max execution time for stored procedure and trigger is 5 seconds.
  • Provisioned document storage / collection is 10GB.
  • Max collections per database account is 100. (so that’s 500 max in account)
  • Max document storage per database 1TB. = Number of collection is up to 100 and that has to be less than 1TB.
  • Max length of the ID property is 255 characters.
  • Max items per page is unlimited. There is no limit here but if I must say that’s 1TB worthy of documents to page.
  • Max request size of document and attachment is 512kb.
  • Max response size is 1MB. (how big or small is 1MB of JSON file?)
  • All request or when you talk to documentDB must be UTF-8 encode standard.
  • Max number of UDFs per query is 2.
  • Max number of JOINs per query is 5.
  • Max number of AND caluse per query is 20.
  • Max number of values per IN expression is 200.
  • Max number of points in a polygon argument in a ST_WITHIN query is 16 (don’t know what this is.. I will look into it later)
  • Max number of collection creates per minute is 5.
  • Max number of scale operations per minute is 5.

Mastering Azure DocumentDB Part 1

If you are looking for a full coverage of DocumentDB and developing web services based on DocumentDB in ASP.Net C# MVC, you have come to the right place. well, almost, working on it.


Index

  • What is DocumentDB
  • Pricing
  • Using DocumentDB
    • Getting Started with .Net SDK
    • CRUD of Database
    • CRUD of Collection

 

What is DocumentDB

DocumentDB is the NoSQL database service from Azure.

DocumentDB is native in JSON, means you can post JSON format data and be able to query them like SQL.  This is convenient in modern web services, because the service is not tied to previously defined data schema, which has been a headache for all web service developers, because the service needs ever improvement and that often means data schema changes.

DocumentDB  is configurable to scale linearly.  This is important concept so I ll cover this fully later.

DocumentDB is manageable via REST API, or can be managed from SDK for JavaScript, Java, Node.js, Python and .Net. But I ll be covering SDK for .Net first.


Pricing

Pricing is applicable at collection level and charged per hour. (What is collection? I ll get to that later) There are 3 tiers, all same storage capacity, difference is how much request units they can handle per second.  Request unit is basically a transaction of the database.

  • S1 250 request unit / sec reserved and  $0.039 per hour (that is up to $29 per month)
  • S2 1,000 request unit / sec reserved and $0.076 per hour (that is up to $57 per month)
  • S3 2,500 request unit / sec reserved  and $0.154 per hour (that is up to $114 per month)

This sounds pretty reasonable for me.  Please be sure to refer to limitation of DocumentDB when you choose your service grade.


 

Using DocumentDB

In DocumentDB, there are 3 layers of structures

  • Database
  • Collection
  • Document

What are all these means?  Don’t worry about details for now-now, but these are containers and how each object exist within.  And I ll talk more about what each of these containers are and mean.


 

Getting Start with .Net SDK

I will be using SDK first, so ., once you create ASP.Net MVC project, the first step is to download SDK. You can nuget it or get it from github (https://github.com/Azure/azure-documentdb-dotnet).  You can also do same by calling REST API, but I will cover that when I use DocumentDB with other programming language later.


The top level container of DocumentDB is database.  So, first, let’s go over CRUD of database.

CRUD of Database

When you work with DocumentDB you need end-point URI and authorized key code.  I will store these values into my Web.config file like below.

If you already know which database to work with, you can also store database name to make your life simpler and easier.

Get A List of Databases

Controller

View

And now you should list of database you have in the account like below.

スクリーンショット_013116_064600_PM

I currently have one in my account already.  Let’s add another one and see.

Create Database

Database is simply a container of JSON document, with capability to have user access logic built in.  If you want to have different user access level at server side, then you can have separate that database and create collections within.  Creating database is free but you can only make up to 100 databases per account.  (see more at limitation of DocumentDB)

Controllers

View

This is what it looks like at input interface.

スクリーンショット_020116_124451_AM

After I run and create database, I am redirected to the list of existing databases and see SandBagDatabase which is database I just added. Super.

スクリーンショット_020116_125044_AM


Now that you can view and add databases, let’s take a look at collections.  Which is one below level container of DocumentDB Databases. Collection is where Azure charges and can choose performance levels and more.

CRUD of Collection

Get A List of Collections

List of collection can be obtained from building CollectionQuery (CreateDocumentCollectionQuery) and running it. That is;

I am totally trusting that databaseName which is passed variable to be rigid, but I may want to think about that later.

Controller

View

Right now I don’t have any collection so I should see nothing like below;

スクリーンショット_020116_020826_AM

Creating Collection

Now let’s create collection and see.

Controller

View

The input interface looks like below;

スクリーンショット_020116_111757_AM

After I type in collection name and click on Create Collection button, now I see new collection being added properly. Super!

スクリーンショット_020116_112448_AM

 

Please continue on to part 2 for reading more about working with Documents.