You are developing a microservice using the Azure Cosmos DB .NET SDK v3. You need to configure a Change Feed Processor to process document updates from a monitored container and coordinate state using a lease container. Which sequence of steps must you perform to initialize and run the Change Feed Processor?
- 1Retrieve Container references for both the monitored container and the lease container from the Cosmos client.
- 2Call GetChangeFeedProcessorBuilder on the monitored container, passing the processor name and the change handler delegate.
- 3Chain builder configuration methods to specify the current host instance name and attach the lease container reference.
- 4Call Build on the builder instance to construct the ChangeFeedProcessor object.
- 5Call StartAsync on the ChangeFeedProcessor instance to begin reading the change feed.
Answer
Retrieve container references, call GetChangeFeedProcessorBuilder on the monitored container, chain builder configuration methods (WithInstanceName and WithLeaseContainer), call Build, and then call StartAsync on the processor.
To successfully configure and run the Change Feed Processor, you must follow the correct lifecycle sequence: first obtain the container references, then initialize the builder on the monitored container, chain configuration methods such as the lease container and instance name, build the processor, and finally start it asynchronously.
Step-by-Step Solution
Key Concept
Azure Cosmos DB .NET SDK v3 Change Feed Processor lifecycle and builder sequence