<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Change-Feed | The .NET Blog</title><link>https://thedotnetblog.com/tags/change-feed/</link><description>Articles, tutorials and insights from the .NET community.</description><generator>Hugo</generator><language>en</language><managingEditor>@thedotnetblog (The .NET Blog)</managingEditor><webMaster>@thedotnetblog</webMaster><lastBuildDate>Fri, 02 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://thedotnetblog.com/tags/change-feed/index.xml" rel="self" type="application/rss+xml"/><item><title>Cosmos DB Change Feed: See Every Version and Delete</title><link>https://thedotnetblog.com/news/emiliano-montesdeoca/cosmosdb-all-versions-deletes-change-feed/</link><pubDate>Fri, 02 Oct 2026 00:00:00 +0000</pubDate><author>Emiliano Montesdeoca</author><guid>https://thedotnetblog.com/news/emiliano-montesdeoca/cosmosdb-all-versions-deletes-change-feed/</guid><description>All Versions and Deletes change feed mode captures creates, intermediate updates, and deletes, with Azure Functions trigger support for .NET workflows.</description><content:encoded>&lt;p&gt;Original source: &lt;a href="https://devblogs.microsoft.com/cosmosdb/azure-cosmos-db-all-versions-and-deletes-change-feed-mode-is-now-generally-available/"&gt;Azure Cosmos DB All Versions and Deletes Change Feed Mode is Now Generally Available&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The default Cosmos DB change feed shows the latest version of an item after a create or update. It does not show deletes, and if an item changes several times between reads, intermediate versions disappear. That is fine for many synchronization jobs, but it is a blocker for audit trails, event sourcing, and systems that need to react differently to a user delete and a TTL expiration.&lt;/p&gt;
&lt;p&gt;All Versions and Deletes change feed mode is now generally available for Azure Cosmos DB for NoSQL. It turns the feed into a more complete event stream and adds support for the Azure Functions trigger in both .NET isolated worker and in-process hosting models.&lt;/p&gt;
&lt;h2 id="what-the-mode-contains"&gt;What the Mode Contains&lt;/h2&gt;
&lt;p&gt;Creates and updates include the current document and an operation type. Deletes include the item ID, partition key, and metadata indicating whether the delete was explicit or caused by TTL expiration. Ordering is preserved, including intermediate updates that the latest-version mode would collapse.&lt;/p&gt;
&lt;p&gt;That enables several patterns:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Audit and compliance records that need every state transition.&lt;/li&gt;
&lt;li&gt;Synchronization to a secondary system without soft-delete flags.&lt;/li&gt;
&lt;li&gt;Delete-triggered cleanup, notifications, or cache invalidation.&lt;/li&gt;
&lt;li&gt;Event sourcing where the full sequence is part of the model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The distinction between explicit delete and TTL expiration can be operationally important. A retention policy event should not automatically be treated as a user request, and the metadata gives downstream code a way to make that decision.&lt;/p&gt;
&lt;h2 id="azure-functions-makes-the-loop-familiar"&gt;Azure Functions Makes the Loop Familiar&lt;/h2&gt;
&lt;p&gt;The Azure Cosmos DB trigger handles lease management, checkpointing, and scaling. In the function, set &lt;code&gt;ChangeFeedMode = CosmosDBChangeFeedMode.AllVersionsAndDeletes&lt;/code&gt; and process a list of &lt;code&gt;ChangeFeedItem&amp;lt;T&amp;gt;&lt;/code&gt; values. The wrapper exposes the current document and metadata for each change. On a delete, the current document is null while the metadata still includes the ID, partition key, and TTL information.&lt;/p&gt;
&lt;p&gt;A simplified shape looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-csharp" data-lang="csharp"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt;[CosmosDBTrigger(
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; databaseName: &amp;#34;store-db&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; containerName: &amp;#34;orders&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; Connection = &amp;#34;CosmosDBConnection&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; LeaseContainerName = &amp;#34;leases&amp;#34;,
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; CreateLeaseContainerIfNotExists = true,
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="na"&gt; ChangeFeedMode = CosmosDBChangeFeedMode.AllVersionsAndDeletes)]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;IReadOnlyList&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ChangeFeedItem&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;changes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Your handler should treat the operation type as data, not infer it from whether the document happens to be present. Log or route creates, replaces, and deletes explicitly, and make the downstream action idempotent because a reliable event stream still needs reliable consumers.&lt;/p&gt;
&lt;p&gt;The source says the trigger works in both isolated and in-process .NET hosting models. Other language support is coming, while the .NET path is available at GA. For more control, the change feed processor and pull model also support this mode.&lt;/p&gt;
&lt;h2 id="you-can-run-both-modes"&gt;You Can Run Both Modes&lt;/h2&gt;
&lt;p&gt;All Versions and Deletes is enabled as an account capability, but the mode is selected per processor, trigger, or pull-model iterator. A container can therefore have one latest-version processor for a simple search-index sync and another all-versions processor for audit logging, using separate lease containers.&lt;/p&gt;
&lt;p&gt;That makes migration less disruptive. Do not change every consumer at once if only one workflow needs historical transitions. Start a dedicated processor, compare its output with the existing consumer, and define retention for the additional event history.&lt;/p&gt;
&lt;h2 id="prerequisites-and-tradeoffs"&gt;Prerequisites and Tradeoffs&lt;/h2&gt;
&lt;p&gt;The source says continuous backup must be enabled before enabling All Versions and Deletes. Turn on the capability from the Azure portal Features page or through the REST API, then install the appropriate Cosmos DB Functions extension for the hosting model.&lt;/p&gt;
&lt;p&gt;The tradeoff is volume. A container with frequent updates will produce more events when intermediate versions are retained, and the consumer must process and store that data responsibly. Estimate throughput, lease behavior, storage, and downstream retry load before enabling the mode on a high-churn container.&lt;/p&gt;
&lt;p&gt;Do not choose this mode solely because “more history” sounds safer. If a consumer only needs the latest state and has no delete-specific workflow, latest-version mode may be simpler and cheaper to operate. The new mode is most valuable when the intermediate state or deletion reason changes the business outcome.&lt;/p&gt;
&lt;h2 id="recommendations-for-net-teams"&gt;Recommendations for .NET Teams&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Enable continuous backup and verify the account prerequisite first.&lt;/li&gt;
&lt;li&gt;Pilot the mode on a non-critical container with a dedicated lease container.&lt;/li&gt;
&lt;li&gt;Upgrade the Azure Functions Cosmos DB extension for the selected hosting model.&lt;/li&gt;
&lt;li&gt;Test create, replace, explicit delete, TTL expiration, ordering, and retry behavior.&lt;/li&gt;
&lt;li&gt;Keep latest-version and all-versions processors separate until the new output is trusted.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;All Versions and Deletes closes a meaningful observability gap in the Cosmos DB change feed. For .NET teams, the important improvement is not only that deletes appear; it is that the platform turns the complete stream into a normal Azure Functions trigger with metadata your code can reason about.&lt;/p&gt;</content:encoded></item></channel></rss>