Azure Cosmos DB now supports distributed transactions in public preview: writes across partition keys, containers and databases commit as one atomic unit through the .NET SDK, replacing hand-built sagas and compensating logic.
Key points
- CreateDistributedWriteTransaction() combines CreateItem, UpsertItem, ReplaceItem, PatchItem and DeleteItem into one all-or-nothing commit.
- Each transaction is capped at 100 operations and 2 MB, inside one account and one region.
- IfMatchEtag plus a FilterPredicate patch rejects stale writes with 412; the transaction can abort with 452.
- Standard mode waits for the final outcome; FastResponse returns early while the commit continues in the background.
- CreateDistributedReadTransaction() reads several items from one committed snapshot, returned in request order.
- Preview requires provisioned throughput, a single-write region and the .NET SDK 3.64.0-preview.0 or later.
Why it matters
For anyone who has written compensating logic for a cross-partition write, this is the first time Cosmos DB itself owns the coordinator: two-phase commit runs in the service, and your code submits one transaction instead of tracking state machines and undo steps.
The catch is the preview shape. It needs provisioned throughput, a single-write region and the .NET 3.64.0-preview.0 SDK, and it is gated behind an enrollment form, so a package bump alone gets you nowhere. Transactional batch stays the right default inside one partition key; treat distributed transactions as the exception for genuinely cross-container invariants.
Real-world use
- A money transfer where two account items and a ledger entry must be written together
- An order and its inventory update living in different containers but committing atomically
- Replacing saga and compensating-transaction code for workflows that cross partition boundaries
This summary was generated by the agent from the original post on Azure Cosmos DB Blog. The full text and all rights belong to its author and publisher. Go to original