AI-200 · 2.1.3 · Develop AI solutions by using Azure data management services
Cosmos vector search
Store and retrieve embeddings and execute vector similarity search for semantic retrieval
Store with items, define a vector policy and index, then rank semantic matches with VectorDistance and TOP N.
Store, index, retrieve

Cosmos DB for NoSQL stores an beside the item it represents. Define the vector path, dimensions and when the container is created, then choose a vector index that fits the workload.
Rank by similarity
SELECT TOP 5 c.title,
VectorDistance(c.contentVector, @embedding) AS score
FROM c
ORDER BY VectorDistance(c.contentVector, @embedding)
The query vector and stored vectors must come from the same embedding model and have matching dimensions. Use quantizedFlat for smaller sets and diskANN when scale and latency matter more than exact recall.
Exclude the vector path from the regular index so normal writes do not also maintain an unnecessary scalar index.
Key points
- : fixed-length number list; same model for stored data and query
- Vector policy: path, data type, dimensions, ; fixed after creation
- : `flat` exact, `quantizedFlat` small sets, `` approximate at scale
- Query: `ORDER BY VectorDistance` plus TOP N; WHERE narrows the vectors ranked
Click an underlined term for a one-line explanation, or see them all in the glossary .
Exam trap
Leaving out TOP N, or using a flat index: flat allows fewer dimensions than most models return, so use quantizedFlat or .
Sources · 3 Microsoft Learn pages Show ▾
- Integrated vector store (Azure Cosmos DB)
- Index and query vector data in Python (Azure Cosmos DB)
- VECTORDISTANCE (Query language for Cosmos DB)
Checked on October 4, 2026. Report a problem
Go deeper on Microsoft Learn
- Integrated vector store (Azure Cosmos DB)
- Index and query vector data in Python (Azure Cosmos DB)
- VECTORDISTANCE (Query language for Cosmos DB)
Checked against Microsoft Learn on October 4, 2026. Report a problem with this card