Skip to content

Commit 0aab05e

Browse files
committed
add all versions and deletes sample for .net to cfp doc
1 parent b957ba5 commit 0aab05e

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

articles/cosmos-db/nosql/change-feed-modes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.reviewer: jucocchi
77
ms.service: cosmos-db
88
ms.custom: build-2023
99
ms.topic: conceptual
10-
ms.date: 08/14/2023
10+
ms.date: 07/25/2024
1111
---
1212
# Change feed modes in Azure Cosmos DB
1313

@@ -121,7 +121,7 @@ During the preview, the following methods to read the change feed are available
121121
| **Method to read change feed** | **.NET** | **Java** | **Python** | **Node.js** |
122122
| --- | --- | --- | --- | --- |
123123
| [Change feed pull model](change-feed-pull-model.md) | [>= 3.32.0-preview](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.32.0-preview) | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.37.0) | No | No |
124-
| [Change feed processor](change-feed-processor.md) | No | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.42.0) | No | No |
124+
| [Change feed processor](change-feed-processor.md) | [>= 3.40.0-preview.0](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.40.0-preview.0) | [>= 4.42.0](https://mvnrepository.com/artifact/com.azure/azure-cosmos/4.42.0) | No | No |
125125
| Azure Functions trigger | No | No | No | No |
126126

127127
> [!NOTE]

articles/cosmos-db/nosql/change-feed-processor.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: cosmos-db
88
ms.subservice: nosql
99
ms.devlang: csharp
1010
ms.topic: conceptual
11-
ms.date: 07/10/2024
11+
ms.date: 07/25/2024
1212
ms.custom: devx-track-csharp, build-2023
1313
---
1414

@@ -51,20 +51,33 @@ Each range is read in parallel. A range's progress is maintained separately from
5151

5252
### [.NET](#tab/dotnet)
5353

54-
The change feed processor in .NET is currently available only for [latest version mode](change-feed-modes.md#latest-version-change-feed-mode). The point of entry is always the monitored container. In a `Container` instance, you call `GetChangeFeedProcessorBuilder`:
54+
The change feed processor in .NET is available for [latest version mode](change-feed-modes.md#latest-version-change-feed-mode) and [all versions and deletes mode](change-feed-modes.md#all-versions-and-deletes-change-feed-mode-preview). All versions and deletes mode is in preview and is supported for the change feed processor beginning in version `3.40.0-preview.0`. The point of entry for both modes is always the monitored container.
55+
56+
To read using latest version mode, in a `Container` instance, you call `GetChangeFeedProcessorBuilder`:
5557

5658
[!code-csharp[Main](~/samples-cosmosdb-dotnet-change-feed-processor/src/Program.cs?name=DefineProcessor)]
5759

58-
The first parameter is a distinct name that describes the goal of this processor. The second name is the delegate implementation that handles changes.
60+
To read using all versions and deletes mode, call `GetChangeFeedProcessorBuilderWithAllVersionsAndDeletes` from the `Container` instance:
61+
62+
[!code-csharp[Main](~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/ChangeFeedAllVersionsAndDeletes/Program.cs?name=BasicInitialization)]
63+
64+
For both modes, the first parameter is a distinct name that describes the goal of this processor. The second name is the delegate implementation that handles changes.
5965

60-
Here's an example of a delegate:
66+
Here's an example of a delegate for latest version mode:
6167

6268
[!code-csharp[Main](~/samples-cosmosdb-dotnet-change-feed-processor/src/Program.cs?name=Delegate)]
6369

70+
Here's an example of a delegate for all versions and deletes mode:
71+
72+
[!code-csharp[Main](~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/ChangeFeedAllVersionsAndDeletes/Program.cs?name=Delegate)]
73+
6474
Afterward, you define the compute instance name or unique identifier by using `WithInstanceName`. The compute instance name should be unique and different for each compute instance you're deploying. You set the container to maintain the lease state by using `WithLeaseContainer`.
6575

6676
Calling `Build` gives you the processor instance that you can start by calling `StartAsync`.
6777

78+
>[!NOTE]
79+
> The preceding code snippets are taken from samples in GitHub. You can get the sample for [latest version mode](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/Usage/ChangeFeed) or [all versions and deletes mode](https://github.com/Azure/azure-cosmos-dotnet-v3/tree/master/Microsoft.Azure.Cosmos.Samples/Usage/ChangeFeedAllVersionsAndDeletes).
80+
6881
## Processing life cycle
6982

7083
The normal life cycle of a host instance is:
@@ -93,6 +106,8 @@ You can connect the change feed processor to any relevant event in its [life cyc
93106
* Register a handler for `WithLeaseReleaseNotification` to be notified when the current host releases a lease and stops processing it.
94107
* Register a handler for `WithErrorNotification` to be notified when the current host encounters an exception during processing. You need to be able to distinguish whether the source is the user delegate (an unhandled exception) or an error that the processor encounters when it tries to access the monitored container (for example, networking issues).
95108

109+
Life cycle notifications are available in both change feed modes. Here's an example of life cycle notifications in latest version mode:
110+
96111
[!code-csharp[Main](~/samples-cosmosdb-dotnet-v3/Microsoft.Azure.Cosmos.Samples/Usage/ChangeFeed/Program.cs?name=StartWithNotifications)]
97112

98113
## Deployment unit
@@ -137,6 +152,8 @@ The change feed processor is initialized, and it starts reading changes from the
137152

138153
> [!NOTE]
139154
> These customization options work only to set up the starting point in time of the change feed processor. After the lease container is initialized for the first time, changing these options has no effect.
155+
>
156+
> Customizing the starting point is only available for latest version change feed mode. When using all versions and deletes mode you must start reading from the time the processor is started, or resume from a prior lease state that is within the [continuous backup](../continuous-backup-restore-introduction.md) retention period of your account.
140157
141158
### [Java](#tab/java)
142159

0 commit comments

Comments
 (0)