← AI-200: cloud development for AI solutions
02 / 6 · 40 MIN

Cosmos DB, vectors, and change feed

Design access and synchronization around partitions, guarantees, and operation cost.

Concept and mechanism

In Cosmos DB, partition key and id identify an item within its scope. When both are known, a point read can avoid a general query. Key selection should consider load distribution and access patterns. A broad indexing policy supports queries but adds write cost; remove paths only after checking usage and measuring impact. Session consistency provides guarantees within a session, with context that may need to cross components. It is not a promise of globally strong reads. For vectors, define the model, dimension, metric, and index policy. Switching embedding models can require reprocessing and migration even when the rest of the document retains the same structure.

Guided application

In a fictional pipeline feeding procedure search, treat change feed as a change contract. Latest-version mode includes creates and updates, can omit intermediate versions, and does not capture physical deletions. If documents must leave the index, design a deletion marker with sufficient retention or an appropriate supported mode. All-versions-and-deletes has its own requirements, including continuous backup and SDK compatibility. The native processor is not equally available in every language: Python can use supported pull or Functions options depending on mode. Consumers should tolerate reprocessing and reconcile external effects. Retain counts, lag, and failures per stage so a green execution does not hide old documents still retrievable.

IN PRACTICE

Deleting a source document does not remove its derived entry when the pipeline only observes latest-version mode without deletion handling.

Common pitfalls

Available RUs as efficient querying; session as every client; vector as an interchangeable array; change feed as all versions and deletes in every SDK.

Related topics: Containers, artifacts, and revisions · PostgreSQL, vectors, and caching · Messages, events, and Functions

Take this idea with you

Define access and change contracts before building synchronization.

Create account

Reference: Latest-version and all-versions-and-deletes modes and SDK support · AI-200 current guide updated2026-05-05; Azure technical documentation2026-09-30