liveBook · Manning

MongoDB API

As explained in Microsoft Azure in Action

The MongoDB API is an interface that enables applications to access Azure Cosmos DB through MongoDB-compatible operations and data representations.

The MongoDB API lets existing MongoDB applications use Azure Cosmos DB without application modifications. It supports MongoDB’s BSON document structure, queries, and drivers, making migration less dramatic than a database rewrite. section 11.2.1

Choose the API that matches the application’s data model and existing technology. MongoDB fits Alpaca-Ma-Bags because its application already uses MongoDB; other Cosmos DB APIs target document, table, PostgreSQL, Cassandra, or graph workloads. section 11.2.1

A MongoDB-compatible Cosmos DB setup follows a straightforward hierarchy:

  • Create a Cosmos DB account with the MongoDB kind and EnableMongo capability. section 11.1
  • Create a MongoDB database inside the account. section 11.1
  • Create a container for documents, choosing a shard key and throughput setting. section 11.1

Alpaca-Ma-Bags migration

Alpaca-Ma-Bags can keep its MongoDB queries and drivers while moving its product data to Cosmos DB. Its account uses Session consistency, and its container can use a shard key with provisioned or autoscaled throughput. section 11.2.1 section 11.1

How Microsoft Azure in Action covers it

How deep it goes
Explains API selection and account-to-database-to-container setup, but does not descend into MongoDB query or driver internals.
Examples
Uses Alpaca-Ma-Bags and Azure CLI commands to create an account, database, container, shard key, and autoscaled throughput.
What it assumes
Assumes familiarity with an existing MongoDB application while defining Cosmos DB’s API, account, database, container, and document structure.
What you can do after
Operate/configure a MongoDB-compatible Cosmos DB account, database, and container through Azure CLI.
How it connects
Ties MongoDB API to Azure Cosmos DB, BSON, MongoDB queries, drivers, databases, containers, shard keys, throughput, and consistency levels.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microsoft Azure in Action. The section links point to the parts of the book it draws on.