As we have seen before, entities inside DocumentDB are called resources. The way resources are managed is a uniform process, and this makes understanding these CRUD operations easier. This section will discuss how to create resources inside your database.
Before you can create and update documents, you first need to have a collection available. In Chapter 1, Getting Started with DocumentDB, we saw how a collection can be created straight from the Azure portal. In this section, we are going to create one by using the .NET SDK using Visual Studio 2013 and C#.
The following code snippet shows how you can check if a collection already exists; it also demonstrates how a collection can be created:
//prerequisite before we can work. We need a DocumentClient and a Database. DocumentClient client = new DocumentClient(new Uri(docDBUri), key); Database database = client.CreateDatabaseQuery().Where(d => d.Id == "devicehub").AsEnumerable().First(); ...