<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti" -->

---
title: See our new Azure Cosmos DB Design Patterns | daily.dev
description: The Azure Cosmos DB Design Patterns GitHub repo has been significantly updated with five new runnable patterns: Vector Search (using a local embedding model...
canonical: https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: See our new Azure Cosmos DB Design Patterns | daily.dev
og:description: The Azure Cosmos DB Design Patterns GitHub repo has been significantly updated with five new runnable patterns: Vector Search (using a local embedding model...
og:url: https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti
og:image: https://api.daily.dev/og/posts/nJn5wi8Ti.png
og:image:alt: See our new Azure Cosmos DB Design Patterns
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# See our new Azure Cosmos DB Design Patterns

**[DevBlogs](https://daily.dev/sources/devblogs)** · 6 min read · 1 upvotes · 0 comments

## Summary

The Azure Cosmos DB Design Patterns GitHub repo has been significantly updated with five new runnable patterns: Vector Search (using a local embedding model for RAG), Loop-Safe Change Feed (preventing infinite write loops with hash-based deduplication), Hierarchical Partition Key (multi-level partitioning for multi-tenant data), Transactional Outbox (atomic dual-write using TransactionalBatch + change feed relay), and Patch API (partial document updates that avoid read-modify-write conflicts). The Distributed Lock pattern was also reworked with a live interactive playground. Every sample runs locally via Docker and the Cosmos DB Linux emulator with no Azure subscription required, features a Blazor web UI, and is backed by emulator-based CI tests on .NET 10 with keyless authentication.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://devblogs.microsoft.com/cosmosdb/see-our-new-azure-cosmos-db-design-patterns>

## Questions this post answers

### How do you avoid an infinite loop when using Cosmos DB change feed to write derived data back to the same document?

Store a hash of the source content on the document, and when processing a change feed event, skip it if the hash is unchanged from the last processed value. This detects the echo of your own write versus a genuine edit, so one real edit produces exactly one enrichment write and one skipped echo instead of triggering the feed again.

_daily.dev surfaces patterns like this for developers debugging runaway change feed loops in Cosmos DB._

### How much cheaper is the Cosmos DB Patch API compared to read-modify-write with an ETag for concurrent updates?

In a three-way concurrency benchmark on the Cosmos DB emulator, Patch cost 2 RU with zero conflicts, while read-modify-write with an ETag cost 6 RU and produced 1 conflict requiring a retry, and read-modify-write without an ETag cost 4 RU but silently lost an update. Patch avoids collisions because it targets only the changed field instead of the whole document.

_daily.dev helps developers weighing Cosmos DB update strategies compare real concurrency trade-offs like these._

### How does the distributed lock pattern in Azure Cosmos DB prevent a crashed lock holder from causing a deadlock?

The lease uses a TTL so it auto-releases if the holder crashes, and the holder carries a fencing token that the protected resource checks before accepting writes. If the lease expires mid-work and another worker takes over, the stale holder's fencing token is rejected, preventing both deadlock and conflicting writes from an outdated holder.

_daily.dev keeps engineers building distributed locking logic informed on patterns like fencing tokens and TTL leases._

## Similar posts on daily.dev

- [Build AI apps with Azure Cosmos DB: Key trends from Cosmos Conf 2026](https://daily.dev/posts/build-ai-apps-with-azure-cosmos-db-key-trends-from-cosmos-conf-2026-9il8x8opp) · Microsoft Azure · 0 upvotes · 0 comments
- [Azure Cosmos DB Playground: Learn and experiment with queries in your browser](https://daily.dev/posts/azure-cosmos-db-playground-learn-and-experiment-with-queries-in-your-browser-mnjctd4uj) · ITNEXT · 0 upvotes · 0 comments
- [Azure Cosmos DB : Becoming a Search-Native Database](https://daily.dev/posts/azure-cosmos-db-becoming-a-search-native-database-xadxo6l12) · DevBlogs · 0 upvotes · 0 comments

---

Tags: [#distributed-systems](https://daily.dev/tags/distributed-systems), [#vector-search](https://daily.dev/tags/vector-search), [#design-patterns](https://daily.dev/tags/design-patterns), [#nosql](https://daily.dev/tags/nosql), [#azure-cosmos-db](https://daily.dev/tags/azure-cosmos-db)

[View this post on daily.dev](https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"See our new Azure Cosmos DB Design Patterns","url":"https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti"},"datePublished":"2026-07-06T20:24:08.135Z","dateModified":"2026-09-13T18:25:43.660Z","description":"The Azure Cosmos DB Design Patterns GitHub repo has been significantly updated with five new runnable patterns: Vector Search (using a local embedding model...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/98ba5cbbd611d276ebf59c2e49ff465a?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/98ba5cbbd611d276ebf59c2e49ff465a?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"DevBlogs","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DevBlogs","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/8f68b453325f482ebeb73fb780092713","url":"https://daily.dev/sources/devblogs"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"distributed-systems,vector-search,design-patterns,nosql,azure-cosmos-db","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DevBlogs","item":"https://daily.dev/sources/devblogs"},{"@type":"ListItem","position":3,"name":"See our new Azure Cosmos DB Design Patterns"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/see-our-new-azure-cosmos-db-design-patterns-njn5wi8ti#faq","mainEntity":[{"@type":"Question","name":"How do you avoid an infinite loop when using Cosmos DB change feed to write derived data back to the same document?","acceptedAnswer":{"@type":"Answer","text":"Store a hash of the source content on the document, and when processing a change feed event, skip it if the hash is unchanged from the last processed value. This detects the echo of your own write versus a genuine edit, so one real edit produces exactly one enrichment write and one skipped echo instead of triggering the feed again. daily.dev surfaces patterns like this for developers debugging runaway change feed loops in Cosmos DB."}},{"@type":"Question","name":"How much cheaper is the Cosmos DB Patch API compared to read-modify-write with an ETag for concurrent updates?","acceptedAnswer":{"@type":"Answer","text":"In a three-way concurrency benchmark on the Cosmos DB emulator, Patch cost 2 RU with zero conflicts, while read-modify-write with an ETag cost 6 RU and produced 1 conflict requiring a retry, and read-modify-write without an ETag cost 4 RU but silently lost an update. Patch avoids collisions because it targets only the changed field instead of the whole document. daily.dev helps developers weighing Cosmos DB update strategies compare real concurrency trade-offs like these."}},{"@type":"Question","name":"How does the distributed lock pattern in Azure Cosmos DB prevent a crashed lock holder from causing a deadlock?","acceptedAnswer":{"@type":"Answer","text":"The lease uses a TTL so it auto-releases if the holder crashes, and the holder carries a fencing token that the protected resource checks before accepting writes. If the lease expires mid-work and another worker takes over, the stale holder's fencing token is rejected, preventing both deadlock and conflicting writes from an outdated holder. daily.dev keeps engineers building distributed locking logic informed on patterns like fencing tokens and TTL leases."}}]}
```

