Working With Azure Cosmos DB

The hands-on lab is part of these learning paths

AZ-203 Exam Preparation: Developing Solutions for Microsoft Azure
course-steps 20 certification 1 lab-steps 7
Architecting Microsoft Azure Solutions
course-steps 10 certification 6 lab-steps 5

Lab Steps

Logging into the Microsoft Azure Portal
Creating an Azure Cosmos DB Database in the Azure Portal
Starting an Azure Cloud Shell
Creating a Cosmos DB Collection With the Azure CLI
Working with the Cosmos DB MongoDB API
Replicating the Cosmos DB Database Globally
Triggering an Azure Function With Cosmos DB Changes
Testing the Azure Function Cosmos DB Trigger

Ready for the real environment experience?

Max Duration2h
star star star star star-half


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:


September 24th, 2019 - Updated instructions due to Azure changes

October 1st, 2018 - Updated instructions and screenshots to match the latest Azure interface and resolved an issue that prevented the Cosmos DB account from being created in certain cases.

About the Author

Learning paths7

Logan has been involved in software development and research since 2007 and has been in the cloud since 2012. He is an AWS Certified DevOps Engineer - Professional, AWS Certified Solutions Architect - Professional, Microsoft Certified Azure Solutions Architect Expert, MCSE: Cloud Platform and Infrastructure, Google Cloud Certified Associate Cloud Engineer, Certified Kubernetes Administrator (CKA), Certified Kubernetes Application Developer (CKAD), Linux Foundation Certified System Administrator (LFCS), and Certified OpenStack Administrator (COA). He earned his Ph.D. studying design automation and enjoys all things tech.