Set up Cosmos DB in Azure

This is a tutorial of how easy it is to set up a CosmosDB. Part of a blog series about Azure Functions and Cosmos DB.

icon of user profile

Published 22 dec 2018

Azure Cosmos DB is Microsoft’s proprietary globally-distributed, multi-model database service “for managing data at planet-scale” launched in May 2017. It builds upon and extends the earlier Azure DocumentDB, which was released in 2014. It is schema-less and generally classified as a NoSQL database.

Prerequisits:

  • Set up a Resource Group – Link

Create a Cosmos DB Account

 

Quickstart helps you with examples

Obtain connection string/key to Cosmos db

To be used with functions (input/output bindings) – check “keys”

Create a Database and Collection

Go to your Cosmos DB > Data Explorer > Add Database > Add Collection

The Partition Key is used to automatically partition data among multiple servers for scalability. Choose a JSON property name that has a wide range of values and is likely to have evenly distributed access patterns.

If you have for example City that is a good partition property.

Throughput 400RU/s is the the lowest and is a good start. Throughput is specified in request units (RUs) per second. The number of RUs consumed for a particular operation depends on a number of factors, but fetching a single 1KB document by its `id` field consumes 1 RU. Delete, update, and insert operations consume around 5 RUs for 1 KB documents.

Further reading

About the author

Luc Gosso
– Independent Senior Web Developer
working with Azure and Episerver

Twitter: @LucGosso
LinkedIn: linkedin.com/in/luc-gosso/
Github: github.com/lucgosso