Azure Cosmos DB: An expert’s introduction

By Alex Bennett, Firebrand Training

Unveiled at Microsoft Build in May, Azure Cosmos DB is the result of a seven-year project to build a database for a global reach.

To talks us through this new product (that many professionals may still be researching), we’re joined by Mike Brown, Lead Azure Instructor at Firebrand Training.

Azure Cosmos DB is Microsoft’s globally-distributed, multi-model database: “With just one click of a button your database can scale and be replicated across multiple Azure regions, without loss of performance,” explains Mike. “It offers scalability, throughput, latency, availability and consistency guarantees backed by solid service level agreements (SLAs).”

Let’s take a closer look at some of the most useful features, use-cases, and resources for Azure Cosmos DB.

 

Multi-model API

Multi-model APIs, writes Mike, are the most powerful feature of Cosmos DB. Imagine you have a MongoDB application with a web tier that’s writing to a MongoDB - by using Cosmos DB’s multi-model API, you’ll be able to copy the data from the MongoDB database into the Cosmos DB.

There’s no need to rewrite the application because the API that Cosmos DB exposes is compatible with MongoDB. This multi API model will make it really easy to migrate existing apps to Cosmos DB.

There are currently four API models that Cosmos DB lets you use:

  • DocumentDB API
  • MongoDB API
  • Graph API
  • Table API

These APIs allow you to program using the tools you’re familiar with, making it easier to migrate some of the most well know NoSQL databases to Cosmos DB.

 

Global Distribution

You’ve just launched your small app in the UK South Azure region. Suddenly, your app explodes in popularity in North America but customers begin to complain about its performance.

Let’s say this issue is caused by the latency inherent in making reads and writes to your UK South-based database from the North America region.

By using Cosmos DB, it’s easy to replicate your UK database to a USA-based region, reducing latency and improving the overall performance of your application. What’s more: Cosmos DB also allows you to associate an unlimited number of regions to your Azure Cosmos DB account, effectively eliminating that read/write latency issue.

You’ll also be able to distinguish regions that are not allowed to be used for your database. This allows you to create failover policies: in the event of an Azure region failure, you’ll keep your database online by controlling the failover regions.

You can create both read and write replicas of your database that follow any of 5 different consistency models:

  • Strong
  • Bounded Staleness
  • Session
  • Consistent Prefix
  • Eventual

More information on consistency levels can be found in Microsoft Cosmos DB documentation.

 

Cosmos DB database security

Data security is a shared responsibility between you, the customer and your database provider. By choosing a PaaS cloud database provider, like Cosmos DB, your area of concern shrinks. Put simply: Microsoft will handle the security of your database, while you manage access.

Azure Cosmos DB comes with a host of security features, including:

  • Documents and backups are encrypted at rest
  • IP-based access controls
  • Role-based access controls
  • Automated online backups
  • Attack monitoring
  • Geo-fencing

 

Use cases for Azure Cosmos DB

“Azure Cosmos DB is ideal for any scenario where you need to write lots of stuff in a very short amount of time, where you don’t want to lose performance no matter how big your database gets,” writes Mike. “This is especially crucial for IoT, gaming, serverless applications and mobile/web apps.”

It’s not just for enterprises or large corporations – traditional on-premises SQL databases don’t offer the flexibility of NoSQL databases. If your application takes-off overnight, the flexibility provided by CosmosDB could be invaluable.

 

What can’t it do?

“Not a lot really,” argues Mike. “Admittedly, Azure DB is not a SQL database, so it can’t be used for complex table joins, but other than that is seems to be a good choice for most scenarios.”

“Other NoSQL databases are good at doing one or two things really well but Cosmos DB has been built from the ground up to be a truly cloud database, supporting many different types of data structures on an almost unlimited scale.”

While competitors do exist (AWS Dynamo DB and Google Cloud Datastore) neither offer the scale or feature-sets that Cosmos DB offers.

“With work, you could create apps and scripts that would make other Cloud-based NoSQL databases work in a similar way to Cosmos DB. But, the point is: you would have to develop that whereas with Cosmos DB it’s there out-of-the-box.”

How to certify your Cosmos DB knowledge

Right now no certifications cover Cosmos DB, but that’s about to change. Significant changes to exam 70-534 (Architecting Microsoft Azure Solutions) are due later this year, resulting in the introduction of Cosmos DB content.

On November 30, 2017, exam 70-534 will be replaced by exam 70-535. The new exam will test content on designing for Cosmos DB storage. A complete list of the changes can be found on Microsoft Learning.

If you’re ready to take a 70-534 course and want to learn more about Cosmos DB, you may want to delay until November for the new content.

However, if you don’t care for the new content, there’s no downside to taking the exam now. When the exam is replaced, it won’t affect any of your previously held certifications.

Click here for a comprehensive list of Microsoft exam retirements in 2017 and 2018.

How to get started with Cosmos DB

In September, Microsoft launched Try Azure Cosmos DB for free, an experience that allows anyone to experience Cosmos DB for a limited time with no sign-up required and no charge.

So, if you’re a developer looking to evaluate Cosmos DB, build and test applications, take a hands-on lab or tutorial – you’ll be able to do all this without incurring any costs.

And if you’re looking for free Azure Cosmos DB resources to get you started, take a look at these 20 short Cosmos DB videos from Azure expert Simona Cotin. Or for something more in-depth, be sure to read the official Cosmos DB documentation.

Useful video content can be found on the official Microsoft YouTube channels, particularly the Azure Friday series (below) or on the Microsoft Mechanics channel.