Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Azure Cosmos DB for NoSQL in 60 seconds

DatabasesPaaS (NoSQL)AWS: Amazon DynamoDB

What it is

A globally distributed JSON database. Items live in containers split by a partition key; every operation costs Request Units. Built-in vector search, change feed and five consistency levels.

Simulate it »

✅ Use it when

  • Chat history and user profiles for AI apps
  • Vector search next to operational data
  • Event-driven pipelines with the change feed

🚫 Not the best fit when

  • Heavy relational joins across many tables

💰 Price feel: ●●○○ Low

Serverless ≈ $0.25 per 1M RUs; provisioned from 400 RU/s ≈ $24/month

Illustrative pay-as-you-go list prices at approximate exchange rates. Use the Azure pricing calculator for real quotes.

Simulate it

3D Data for AI apps: Cosmos DB, PostgreSQL and Redis Create a container with a partition key.

🖱️ Drag to rotate · scroll or pinch to zoom

Loading the 3D scene…
</> Embed

Embed this simulation

Free for trainers, teachers and bloggers. Paste this into your page:

Cosmos DB: items, partitions, RUs

In Azure Cosmos DB for NoSQL, JSON items live in containers, spread across logical partitions by the partition key. Every operation costs Request Units (RUs). A point read by id and partition key costs about 1 RU. A query that scans every partition costs far more.

Read this tour as text
  1. Text becomes a vector. An embedding model turns text into a list of numbers, a vector (1,536 numbers for text-embedding-3-small). Texts that mean similar things get vectors that sit close together, so "refund" lands near "money back".
  2. Cosmos DB: items, partitions, RUs. In Azure Cosmos DB for NoSQL, JSON items live in containers, spread across logical partitions by the partition key. Every operation costs Request Units (RUs). A point read by id and partition key costs about 1 RU. A query that scans every partition costs far more.
  3. Indexing and consistency. By default Cosmos DB indexes every property, so writes cost more RUs. An indexing policy can exclude paths you never filter on, such as the big embedding array. Consistency levels trade freshness for speed and cost: Strong, Bounded staleness, Session (default), Consistent prefix, Eventual.
  4. Vector search in Cosmos DB. A vector embedding policy tells Cosmos DB where the vectors are, their dimensions and distance function. A vector index makes search fast: diskANN or quantizedFlat for large sets, or flat for exact search on small vectors (up to 505 dimensions). Then ORDER BY VectorDistance(c.embedding, @q) returns the closest items.
  5. Change feed. The change feed is an ordered log of inserts and updates in a container (deletes only show up in the *all versions and deletes* mode). A change feed processor reads it with a lease container that remembers how far each worker got, so a new product can be embedded the moment it’s saved.
  6. PostgreSQL with pgvector. In Azure Database for PostgreSQL, the pgvector extension adds a vector(1536) column type. Without an index, every search compares against every row (a sequential scan). An HNSW or IVFFlat index finds near neighbours fast, trading a little recall for a lot of speed.
  7. RAG with a metadata filter. Retrieval-augmented generation (RAG): embed the question, fetch the closest chunks (ORDER BY embedding <=> $1 LIMIT 5), filter by metadata such as tenant_id or lang, then send those chunks to the model as context. The answer is grounded in your own data.
  8. Azure Managed Redis. Azure Managed Redis keeps hot data in memory. Cache-aside: check Redis, and on a miss read the database and store the result with a TTL. When data changes, invalidate the key. Redis can also hold a vector index for fast similarity search, for example a semantic cache of answers.
📘 Full lesson: Cosmos DB for NoSQL: Connect with the SDK and Query ❯ ⚖️ Cosmos DB vs PostgreSQL vs Redis for Vector Search ❯

Similar services

Install MSDEVBUILD Azure

Free · no account · works offline

Save the whole course for offline ›

Hi, I’m your Nimbus

Your study buddy. Pick what we do next.

MSDEVBUILD · Multi-Stack Dev Build

Sign in to MSDEVBUILD

One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.