Working With Azure Cosmos DB

Intermediate

17 students completed the lab in ~54m

Total available time: 1h:30m

Be the first to rate this lab!

Lab Overview

Azure Cosmos DB is a fully-managed, globally-distributed, multi-model database. Databases in Cosmos DB are enterprise-ready and highly-available offering up to 99.999% availability SLA. In this Lab, you will learn how to manage Cosmos DB using the Azure Portal and Azure CLI as you integrate Azure Functions with Cosmos DB change feed triggers to buy and sell fictitious stocks. This Lab uses the MongoDB API in Cosmos DB to work with a document database model.

Lab Objectives

Upon completion of this Lab, you will be able to:

  • Understand the multi-model capabilities of Cosmos DB
  • Perform geo-replication and failovers in Cosmos DB
  • Understand the tradeoffs involved in deciding on a concurrency model and throughput level in Cosmos DB
  • Connect to MongoDB API Cosmos DB databases using MongoDB clients
  • Trigger Azure Functions whenever a document changes in a Cosmos DB database

Lab Prerequisites

You should be familiar with:

  • The concept of NoSQL and document databases
  • MongoDB commands are beneficial, but not required
  • Azure Function experience is beneficial, but not required

Lab Environment

Before completing the Lab instructions, the environment will look as follows:

After completing the Lab instructions, the environment should look similar to:

Follow these steps to learn by building helpful cloud resources

Logging into the Microsoft Azure portal

Begin the Lab by logging into the Microsoft Azure portal

Creating an Azure Cosmos DB Database in the Azure Portal

Create an Azure Cosmos DB Database using the Azure Portal

Starting an Azure Cloud Shell

Learn how to start an Azure Cloud Shell

Creating a Cosmos DB Collection With the Azure CLI

Use the Azure CLI to create a collection to store stock ticker information

Working with the Cosmos DB MongoDB API

Use the Portal and Cloud Shell to work with the MongoDB API of the Cosmos DB database

Replicating the Cosmos DB Database Globally

Enable global distribution of the Cosmos DB database and perform a manual failover

Triggering an Azure Function With Cosmos DB Changes

Create an Azure Function to process the Cosmos DB change feed

Testing the Azure Function Cosmos DB Trigger

Try out the Cosmos DB-triggered function