You are developing a .NET application using the Azure Cosmos DB .NET SDK v3. The application must process changes from a source container using the Change Feed Processor and send real-time notifications. You need to configure and start the Change Feed Processor. How should you sequence the steps to initialize, configure, and start the Change Feed Processor?
- 1Define the delegate method that handles the read-only collection of modified documents.
- 2Retrieve Container references for the monitored container and the lease container.
- 3Call GetChangeFeedProcessorBuilder on the monitored container, passing the delegate and a unique processor name.
- 4Chain WithLeaseContainer and WithInstanceName on the builder to specify the leases and host identity.
- 5Invoke Build on the builder to instantiate the processor, and call StartAsync on the resulting processor instance.
Answer
To initialize the Change Feed Processor using the .NET SDK v3, you must first define the delegate that will handle the changes, retrieve the Container references for the monitored and lease containers, invoke GetChangeFeedProcessorBuilder on the monitored container, configure the builder with the lease container and instance name, and finally build and start the processor asynchronously.
The correct sequence begins by defining the change processing delegate and acquiring the required Container SDK instances. You then initialize the builder using the source container, configure the leases and host identity using fluent methods on the builder, and complete the process by invoking Build and starting the processor.
Step-by-Step Solution
Key Concept
The initialization sequence of the Azure Cosmos DB Change Feed Processor requires setting up dependencies (delegate, containers) before configuring the builder and starting the background reader.