RESTful interactions with Azure Cosmos DB resources using the DocumentDB API, CRUD operations, API for MongoDB and additional quick starts

Azure Cosmos DB is a globally distributed system that supports the document, graph, and key-value data models which Microsoft have classified as a multi-model database service for mission-critical systems.

It also supports both the API for MongoDB and the DocumentDB API for creating, querying, and managing resources.

If you would like to understand how to answer any of the following questions: –

  • How do the standard HTTP methods work with Azure Cosmos DB resources?
  • How do I create a new resource using POST?
  • How do I register a stored procedure using POST?
  • How does Azure Cosmos DB support concurrency control?
  • What are the connectivity options for HTTPS and TCP?
Cosmos DB - interactions-with-resources2

Interaction model using the standard HTTP methods

Then take a look at Azure Cosmos DB REST API for full details first published on 18th July 2017 which covers these topics.


If interested in performing CRUD operations using REST, see Common tasks using the Azure Cosmos DB REST API.


If interested in performing CRUD operations using C# and REST, see the REST from .NET Sample on GitHub which can help you out.


If interested in more details of the MongoDB API, then see Introduction to Azure Cosmos DB: API for MongoDB which covers the benefits of using Azure Cosmos DB for MongoDB applications.

cosmosdb-mongodb

MongoDB wire protocol


… and finally if looking for help getting started then the following MongoDB quick starts will help you out: –

and also: –

 

Azure Cosmos DB with Scott Hanselman

Published on Jun 27, 2017

Kirill Gavrylyuk stops by Azure Friday to talk Cosmos DB with Scott Hanselman.

Watch this quick overview of the industry’s first globally distributed multi-model database service followed by a demo of moving an existing MongoDB app to Cosmos DB with a single config change.

For more information, see: https://azure.microsoft.com/en-us/services/cosmos-db/

Querying Azure Cosmos DB resources using the REST API

Cosmos DB REST API Query
Azure Cosmos DB is a globally distributed multi-model database with support for multiple APIs. This is a link to an article which describes how to use REST to query resources using the Azure Cosmos DB API – https://docs.microsoft.com/en-us/rest/api/documentdb/querying-documentdb-resources-using-the-rest-api

All Cosmos DB resources (with the exception of account resources) can be queried using Azure Cosmos DB SQL language. See Query with Azure Cosmos DB SQL for additional details on syntax – http://azure.microsoft.com/documentation/articles/documentdb-sql-query

For a full sample using .NET visit https://github.com/Azure/azure-documentdb-dotnet/tree/master/samples/rest-from-.net

Build a Node.js or Java web app for Azure Cosmos DB

Simple Java Web App for Cosmos DB
These two articles for Node.js and Java are tutorials that explores how to use Microsoft Azure Cosmos DB to store and access data from a Node.js Express or Java web application hosted on Azure Websites.

https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-nodejs-application
and
https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-java-application

Develop locally with the Azure Cosmos DB Emulator

CosmosDB Emulator
The Azure Cosmos DB Emulator provides a local development environment that emulates the Azure Cosmos DB service. Using this you can develop and test your application locally, without the need for an Azure subscription or incurring any costs. Once development is complete and you are ready, you can switch across to using an Azure Cosmos DB account in the cloud.

This is a handy article which covers the following tasks:

  • Installing the Emulator
  • Running the Emulator on Docker for Windows
  • Authenticating requests
  • Using the Data Explorer in the Emulator
  • Exporting SSL certificates
  • Calling the Emulator from the command line
  • Collecting trace files

https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator

There are some limitations to the Emulator, when compared to the highly scalable cloud version, below is an outline of some of the differences…

Azure Cosmos DB Emulator Azure Cosmos DB Cloud Service
Supports only a single fixed account and a well-known master key. Key regeneration is not possible. Supports multiple accounts and different master keys. You can regenerate keys any time from Azure Portal
Non scalable. Highly scalable
Does not support larger data sets. Support for large data sets
Does not simulate consistency levels. Different Consistency levels available
Does not simulate multi-region replication. Configurable as part of the platform, as needed basis
Does not support quota override feature. Supports document size limit increases, increased partitioned collection storage etc.
Will not support most recent changes to Cosmos DB platform. Most recent platform updates are available

 

Azure Cosmos DB – Lessons learnt from building a globally distributed database from the ground up

slide_0

In this talk, I describe the key capabilities, system design and various design trade-offs we had to make in the process of building Cosmos DB (http://cosmosdb.com) service. I also share our experience from operating a globally distributed database service worldwide and maintaining comprehensive Service Level Agreements (SLAs).


https://speakerdeck.com/dharmashukla/azure-cosmos-db-lessons-learnt-from-building-a-globally-distributed-database-from-the-ground-up