1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Introduction to Azure Cosmos DB

Cosmos DB API


Introduction to Cosmos DB
1m 58s
Start course
1h 8m

Cosmos DB is one of many database solutions in a crowded market. From DynamoDB to Cassandra to CockroachDB, the questions one would naturally ask when examining Cosmos DB are, “what makes it special, and how can I get started with it?”

This course answers both of those questions as thoroughly and concisely as possible. This course is for anyone with an interest in database technologies or creating software using Microsoft Azure. Whether you are a DevOps engineer, a database admin, a product manager, or a sales expert, this course will help you learn how to power your technology with one of Azure's most innovative data solutions.

From this course, you will learn how to make use of Cosmos DB's incredible flexibility and performance. This course is made up of nine comprehensive lectures to guide you from the basics to how to create your own app using Cosmos DB.

Learning Objectives

  • Learn the basic components of Cosmos DB
  • Learn how to use Cosmos DB via the web portal, libraries, and CLI tools
  • Learn how to create an application with Cosmos DB as the data backend

Intended Audience

  • People looking to build applications using Microsoft Azure
  • People interested in database technologies


  • General knowledge of IT architecture
  • General knowledge of databases

So we've got our Cosmos DB account set up. We can select a desired data API, create databases, write arbitrary data, and execute queries all from the browser. We're ready to administer our data intelligently. Swell right? Well, in all likelihood you'll not be doing all of your database reading and writing manually via GUI. You need applications and tools to be able to talk to Cosmos DB. You may want your web app to serve requests to Cosmos DB or you may have devops scripts that have to execute Cosmos DB queries. This is where the Cosmos DB API comes into play. The API documentation is divided by data model, meaning there are separate docs for a Cassandra API, MongoDB, Gremlin, SQL, Azure Table. When you select one you will get information for how to set up your development environment depending on your language choice. Cosmos DB has strong support for many languages including .NET, Java, Python, Ruby, JavaScript. The best way to get started is to look through the SDK documentation for the language of your choice. So for example, let's say we wanted to use Cosmos DB's SQL API with, oh I don't know, how about Java. 

The documentation will link us to a GitHub repo for the Java Cosmos DB SDK. There you'll find a nice README and walkthrough to help you set up the SDK with your Java IDE and begin writing code that could interact with Cosmos DB. Now in some cases you won't use a Cosmos DB SDK specifically, but rather a driver meant for whatever data model API you selected. So, for example, if we go through the Cosmos DB Python quick start guide for a Cassandra API server, the setup documentation links to the Python Cassandra driver GitHub repo. The Python code you write for Cosmos DB in this instance will be just like Python code for a Cassandra app. You will import the Python Cassandra driver and use its methods to connect, write, and query your Cosmos DB. This flexibility, I think, is one of the most powerful things about Cosmos DB. What it does is it makes it so that if you already have expertise in one database technology, like Mongo or SQL, you can leverage that and often reuse the same code in SDKs. The only new overhead is ensuring your applications have the right permissions and authorization to actually connect to your Cosmos DB account. We'll drill down about that in section three when we build a real service. Furthermore, with Cosmos DB we have more than just SDKs, and in the web console we have CLI tools and a REST API and Powershell. 

Using the Azure CLI tool we can do all of the things we did with the web console in the previous lessons. Now see the links below for the complete command reference. We're not gonna go through every command. There is also a nice set of BASH scripts in that link that make use of the CLI tool to set up and manage your databases. They have them throughout the Azure documentation. With Powershell we can do everything from the CLI as well as scripting. So if you're comfortable writing Powershell code you can do many of the same things as you would in BASH scripts, only it'll probably require fewer lines of code. And then finally you have the REST API. This lets you do everything your own way with any programming language that can make HTTP requests or you can just use curl, if it pleases you. So as we can see from this section, Cosmos DB is both very powerful and very flexible. We can do most of our setup, configuration, and maintenance from the web console or using command line tools. When it comes time for our software to read and write data we have options for many languages and workarounds for unusual use cases. All of this surely sounds great, and by now you have enough theoretical understanding to dive in, build your own little app with Cosmos DB. However, to help ensure you start strong in section three we're gonna walk through building an application, using Azure services, and Cosmos DB. It's gonna be a blast, see you there.

About the Author

Jonathan Bethune is a senior technical consultant working with several companies including TopTal, BCG, and Instaclustr. He is an experienced devops specialist, data engineer, and software developer. Jonathan has spent years mastering the art of system automation with a variety of different cloud providers and tools. Before he became an engineer, Jonathan was a musician and teacher in New York City. Jonathan is based in Tokyo where he continues to work in technology and write for various publications in his free time.