Question

Difficulty: MediumProcess Azure Cosmos DB Change Feed Notifications

An enterprise application stores user profile updates in an Azure Cosmos DB container named Profiles. You need to implement two separate microservices using the .NET SDK v3: one to update a search index, and another to send welcome emails. Both microservices must process all change feed notifications from the Profiles container independently. You plan to use a single shared container named leases to store the lease state.

Which two of the following configuration steps must you perform to ensure both microservices process all changes?

  1. Configure each microservice's change feed processor with a unique processor name using the WithProcessorName method.Answer
  2. Configure both change feed processors to point to the leases container as their lease container.Answer
  3. C
    Configure the leases container with a partition key of /userId to match the partition key of the monitored Profiles container.
  4. D
    Configure both microservices to use the same processor name in the WithProcessorName method to enable parallel execution.

Answer

Configure each microservice's change feed processor with a unique processor name using the WithProcessorName method, and configure both change feed processors to point to the leases container as their lease container.
To process change feed notifications independently for multiple distinct business requirements, each microservice must represent a separate logical consumer group. In the Azure Cosmos DB .NET SDK v3, this is achieved by assigning a unique processor name to each Change Feed Processor instance via the WithProcessorName method. When sharing a single lease container, the unique processor name acts as a prefix key namespace, allowing both microservices to store and manage their leases in the same container without interfering with each other.

Step-by-Step Solution

1
Determine the separation of concerns for the microservices.
Since the search index updater and the welcome email sender must process all updates independently, they represent two distinct consumer groups.
Independent processing requires separate lease tracking to ensure one service's progress doesn't affect the other's.
2
Configure the lease storage mechanism.
Initialize both processors using the same lease container named 'leases', but assign different processor names using the WithProcessorName builder method.
Unique processor names allow multiple independent consumer groups to share the same lease container without conflicts.
3
Verify lease container requirements.
Ensure the 'leases' container is provisioned with /id as the partition key, not matching the monitored container's partition key (/userId).
The Cosmos DB .NET SDK v3 Change Feed Processor specifically requires the lease container to have /id as its partition key.

Key Concept

Azure Cosmos DB Change Feed Processor Multi-Consumer Configuration
Rate this question