{"id":12240,"date":"2026-06-02T12:15:20","date_gmt":"2026-06-02T19:15:20","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cosmosdb\/?p=12240"},"modified":"2026-06-03T09:52:15","modified_gmt":"2026-06-03T16:52:15","slug":"announcing-public-preview-of-distributed-transactions-in-azure-cosmos-db-for-nosql","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cosmosdb\/announcing-public-preview-of-distributed-transactions-in-azure-cosmos-db-for-nosql\/","title":{"rendered":"Announcing Public Preview of Distributed Transactions in Azure Cosmos DB for NoSQL"},"content":{"rendered":"<p>In modern cloud-native applications, correctness is often hardest to maintain at the exact moment a workflow crosses boundaries. A checkout flow writes an order in one place; decrements inventory in another and emits an audit event somewhere else. A money movement workflow debits one account, credits another, and records the transfer for compliance. An AI workflow updates state across multiple services while coordinating retries, handoffs, and downstream actions. Each step is individually straightforward. Keeping the entire workflow correct under partial failures, concurrent updates, retries, and regional events is where the real engineering effort begins.<\/p>\n<p>Developers know this pattern well. One write succeeds, another times out, and now the system has to decide whether to retry, compensate, reconcile, or wait for a background repair process. What starts as business logic quickly turns into saga orchestration, compensation logic, idempotency safeguards, conditional checks, and increasingly fragile retry behavior. Over time, maintaining cross-service consistency becomes its own subsystem \u2014 one that is difficult to implement, hard to test exhaustively, and expensive to operate at global scale.<\/p>\n<h2>Where existing approaches fall short<\/h2>\n<p>This challenge is especially familiar in distributed data architectures, where the application must preserve invariants across entities that do not live in the same partition, container, or database. Azure Cosmos DB for NoSQL has long supported atomic, multi-document writes through stored procedures and the Batch API in the SDK. Those mechanisms work great \u2014 as long as every document you\u2019re modifying shares the same partition key inside a single container. But real systems rarely line up so neatly.<\/p>\n<p>A money transfer touches two customer entities that live on different partitions. An order placement decrements stock in one container and writes an audit row in another. A multi-tenant state change updates two related entities with different partition keys. Until now, getting this right required compensation logic, sagas, or carefully orchestrated retries \u2014 patterns that are complex to implement, test, and operate.<\/p>\n<h2>Introducing distributed transactions in Azure Cosmos DB<\/h2>\n<p>Today, we\u2019re excited to announce the public preview of distributed transactions in Azure Cosmos DB for NoSQL. With a single API call, your application can now commit a set of writes atomically across partitions, containers, and databases in the same account \u2014 without giving up the scale, global distribution, and elasticity of Azure Cosmos DB. Either every operation in the transaction commits and becomes visible together, or none of them apply. There\u2019s no partial state, no half-written orders, no application-level sagas to maintain. Just one call, all or nothing. This closes a key gap for developers who previously had to implement cross-partition consistency in the application layer.<\/p>\n<p>Either every operation in the transaction commits and becomes visible together, or none of them apply. There\u2019s no partial state, no half-written orders, no application-level sagas to maintain. Just one call, all or nothing. This closes a key gap for developers who previously had to implement cross-partition consistency in the application layer.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer.png\"><img decoding=\"async\" class=\"aligncenter wp-image-12302 size-large\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1024x683.png\" alt=\"Distributed Transactions in Azure Cosmos DB\" width=\"1024\" height=\"683\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1024x683.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-300x200.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-768x512.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h2>What this unlocks<\/h2>\n<p>Azure Cosmos DB for NoSQL has long supported atomic, multi-document writes through stored procedures and the Batch API in the .NET SDK. Those mechanisms work great \u2014 as long as every document you\u2019re modifying shares the same partition key inside a single container.<\/p>\n<p>Real applications rarely have that luxury. A money transfer touches two customer entities that live on different partitions. An order placement decrements stock in one container and writes an audit row in another. A multi-tenant state change updates two related entities with different partition keys. Until now, getting this right required compensation logic, sagas, or carefully orchestrated retries \u2014 patterns that are complex to implement, test, and operate.<\/p>\n<p>Distributed transactions extend atomicity beyond a single partition; the set of operations is committed as a single atomic unit.<\/p>\n<h2>What you can do today<\/h2>\n<p>Azure Cosmos DB for NoSQL supports cross-partition read transactions and cross-partition write transactions \u2014 letting your application reason about related items together, even when they live across partitions, containers, and databases in the same account.<\/p>\n<h3>Cross-partition write transactions<\/h3>\n<p>With a single distributed write transaction, you can perform a set of write operations atomically across partitions. A cross-partition write transaction lets you:<\/p>\n<ul>\n<li>Write to multiple items with different partition key values within a container.<\/li>\n<li>Span multiple containers across databases within the same account.<\/li>\n<li>Combine create, upsert, replace, patch, and delete operations in a single atomic unit.<\/li>\n<li>Include ETag-based conditional checks so writes commit only if the items haven\u2019t changed since you read them.<\/li>\n<li>Perform read-driven validation as part of the transaction, ensuring correctness before committing changes \u2014 for example, validating account balances, checking inventory, or enforcing state transitions.<\/li>\n<\/ul>\n<p>Here\u2019s an order placement \u2014 order, line item, and audit event \u2014 composed into a single atomic write across containers and databases:<\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">\/\/ Create an order, its line item, and an audit event atomically\r\n\/\/ \u2014 across containers and databases in the same account\r\nDistributedTransactionResponse response = await client\r\n    .CreateDistributedWriteTransaction()\r\n    .CreateItem(\"commerce\", \"orders\",     new PartitionKey(order.CustomerId), order)\r\n    .CreateItem(\"commerce\", \"orderItems\", new PartitionKey(item.OrderId),     item)\r\n    .CreateItem(\"audit\",    \"events\",     new PartitionKey(evt.Date),         evt)\r\n    .CommitTransactionAsync(CancellationToken.None);\r\n<\/code><\/pre>\n<h3>Cross-partition read transactions<\/h3>\n<p>A cross-partition read transaction returns a consistent view of items or documents that live across partitions, containers, or databases. This is useful when your application needs to read related entities together \u2014 for example, fetching a customer\u2019s account and their open orders \u2014 and reason about them as a snapshot, without interference from concurrent writes.<\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">\/\/ Read the order, its line item, and the audit event as a consistent snapshot\r\nDistributedReadTransaction txn = client.CreateDistributedReadTransaction();\r\n\r\ntxn.ReadItem(\"commerce\", \"orders\",     new PartitionKey(customerId), orderId)\r\n   .ReadItem(\"commerce\", \"orderItems\", new PartitionKey(orderId),    lineItemId)\r\n   .ReadItem(\"audit\",    \"events\",     new PartitionKey(auditDate),  auditId);\r\nDistributedTransactionResponse response = await txn.CommitTransactionAsync();\r\n<\/code><\/pre>\n<h3>Transactional boundaries honored across failovers<\/h3>\n<p>Distributed transactions compose with your account\u2019s consistency level. In public preview, Azure Cosmos DB also honors transactional boundaries through a regional failover \u2014 a capability that ensures the all-or-nothing guarantee remains intact even when the active write region changes.<\/p>\n<p><iframe src=\"\/\/www.youtube.com\/embed\/1HSMkrT6hkk\" width=\"560\" height=\"314\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h2>Where this delivers value off<\/h2>\n<p>Distributed transactions are designed for workloads where correctness across partitions matters as much as throughput. A few patterns where this pays off immediately:<\/p>\n<ul>\n<li>Money movement and ledgers \u2014 debit one account, credit another, and write the audit row, with no possibility of a partial transfer. The accounts almost always live on different partitions.<\/li>\n<li>Order management and inventory \u2014 atomically reserve stock in one container, create the order in another, and emit an audit event \u2014 instead of a saga that has to reverse half the world on failure.<\/li>\n<li>Identity and multi-tenant state \u2014 update a user record, their tenant membership, and a permissions document together, even when those entities are partitioned by different keys.<\/li>\n<li>Idempotent business workflows \u2014 long-running workflows that must be retried safely after partial failure. The UUID v4 idempotency token makes safe retry the default, not an application-layer obligation.<\/li>\n<li>Cross-entity invariants \u2014 anywhere your domain has a \u201cthese writes must succeed together\u201d rule that today is enforced by careful retry logic, sagas, or a separate transactional engine.<\/li>\n<\/ul>\n<p>If your workload only needs atomicity across documents that share a partition key, keep using the existing Batch API \u2014 it remains the lower-latency choice. Distributed transactions are the right tool when the data that must move together doesn\u2019t fit on a single partition.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-12306 size-large\" src=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1-1024x683.png\" alt=\"Infographic titled &quot;Distributed Transactions in Azure Cosmos DB for NoSQL&quot; explaining atomic transactions across partitions, containers, and databases. Five illustrated real-world scenarios are shown: money movement and ledgers, order management and inventory, identity and multi-tenant state, idempotent business workflows, and cross-entity invariants. Each panel includes icons and descriptions demonstrating transactional consistency, reliability, and correctness. A footer banner highlights stronger correctness, simpler applications, and global scale, alongside the Azure Cosmos DB logo.\" width=\"1024\" height=\"683\" srcset=\"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1-1024x683.png 1024w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1-300x200.png 300w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1-768x512.png 768w, https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-content\/uploads\/sites\/52\/2026\/05\/Designer-1.png 1536w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<h3><span style=\"font-size: 16px;\">Get started<\/span><\/h3>\n<ol>\n<li>Request <a href=\"https:\/\/aka.ms\/cosmosdb\/dtx-onboard\">enrollment<\/a> for your accounts.<\/li>\n<li>Install the Azure Cosmos DB .NET v3 preview (<a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.Azure.Cosmos\/3.62.0-preview.0\">v3.62.0-preview.0<\/a>) SDK<\/li>\n<li>Read the <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/how-to-configure-and-use-distributed-transactions\">how-to<\/a> guide on Microsoft Learn for the full model, limits, and patterns.<\/li>\n<\/ol>\n<p>If you have questions, reach out to <a href=\"mailto:azcosmosdbdtxpreview@microsoft.com\">azcosmosdbdtxpreview@microsoft.com<\/a>.<\/p>\n<h2>Learn more<\/h2>\n<ul>\n<li>How-to: <a href=\"https:\/\/learn.microsoft.com\/en-us\/azure\/cosmos-db\/how-to-configure-and-use-distributed-transactions\">Use distributed transactions in Azure Cosmos DB for NoSQL<\/a><\/li>\n<\/ul>\n<p>We can\u2019t wait to see what you build \u2014 especially as developers bring stronger correctness guarantees to the cloud-native applications, AI workflows, and globally distributed systems that increasingly define modern software.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In modern cloud-native applications, correctness is often hardest to maintain at the exact moment a workflow crosses boundaries. A checkout flow writes an order in one place; decrements inventory in another and emits an audit event somewhere else. A money movement workflow debits one account, credits another, and records the transfer for compliance. An AI [&hellip;]<\/p>\n","protected":false},"author":189973,"featured_media":12499,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-12240","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-sql-api"],"acf":[],"blog_post_summary":"<p>In modern cloud-native applications, correctness is often hardest to maintain at the exact moment a workflow crosses boundaries. A checkout flow writes an order in one place; decrements inventory in another and emits an audit event somewhere else. A money movement workflow debits one account, credits another, and records the transfer for compliance. An AI [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/users\/189973"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/comments?post=12240"}],"version-history":[{"count":3,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12240\/revisions"}],"predecessor-version":[{"id":12533,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/posts\/12240\/revisions\/12533"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media\/12499"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/media?parent=12240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/categories?post=12240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cosmosdb\/wp-json\/wp\/v2\/tags?post=12240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}