Soru

Zorluk: OrtaProcess Azure Cosmos DB Change Feed Notifications

You are designing a serverless solution in Azure. You have an Azure Cosmos DB container named Orders. You deploy two separate Azure Functions, ProcessInvoice and UpdateInventory, within the same Function App. Both functions are triggered by changes in the Orders container using the Azure Cosmos DB trigger (CosmosDBTrigger). You configure both triggers to share a single lease container named leases to minimize resource consumption.

During testing, you observe that the two functions compete for partition leases, resulting in each update being processed by only one of the functions, rather than both. You need to ensure that both functions independently process every change feed event from the Orders container.

Which configuration action should you perform?

  1. A
    Re-create the leases container using a custom partition key such as /functionName to isolate the leases for each function.
  2. B
    Configure ProcessInvoice to use a system-assigned managed identity and UpdateInventory to use a user-assigned managed identity for database connection.
  3. Configure a unique LeaseContainerPrefix (such as invoices_ and inventory_) for each function's trigger attribute.Cevap
  4. D
    Scale out the Function App by migrating the hosting plan from the Consumption plan to a Dedicated App Service plan.

Cevap

Configure a unique LeaseContainerPrefix (such as invoices_ and inventory_) for each function's trigger attribute.
Configuring a unique LeaseContainerPrefix allows both functions to use the same lease container while maintaining separate lease tracking documents. Each function acts as an independent consumer group, processing every update in the change feed.

Adım Adım Çözüm

1
Analyze the competing consumer behavior of the Azure Functions Cosmos DB trigger.
Identify that when multiple triggers share the same lease container and do not specify a unique prefix, they share the same lease documents and partition ownership, acting as a single consumer group.
This explains why only one function processes a given partition update instead of both functions receiving all updates.
2
Determine the parameter required to isolate lease scopes within the same container.
Identify LeaseContainerPrefix as the attribute property that appends a custom prefix to lease documents, creating separate logical partition tracking.
This allows both functions to run as independent consumer groups while sharing a single physical container.

Anahtar Kavram

Using LeaseContainerPrefix in CosmosDBTrigger to support multiple independent consumer groups sharing a lease container.
Tahmini Süre:1m 30s
Bu soruyu puanla