You are building a stock inventory system that must maintain a per-item count with high concurrency and guarantee that updates for the same item are serialized. Multiple clients will increment and decrement inventory and occasionally read the current count. Which two actions should you take using Durable Functions?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a Durable Entity function (e.g., Inventory) that defines operations such as AddStock and RemoveStock and maintains state in the entity context., From an HTTP-triggered function, construct an EntityId ("Inventory", itemId) and call IDurableEntityClient.SignalEntityAsync to send updates; use ReadEntityStateAsync to query current stock..
Why this is the answer
Durable Entities are designed for managing stateful objects with high concurrency and guaranteed single-threaded access for operations on a specific entity instance. Creating a Durable Entity function (e.g., Inventory) with operations like AddStock and RemoveStock ensures that all updates for a given item are serialized, preventing race conditions. To interact with this entity, an HTTP-triggered function can use IDurableEntityClient.SignalEntityAsync to send non-blocking messages for updates and ReadEntityStateAsync to query the current state. Incorrect options: IDurableOrchestrationClient.StartNewAsync is for starting orchestrations, not for managing concurrent state for a single item. Orchestrations are for workflows, not stateful objects with serialized access. Storing counts in a static in-memory dictionary with C locks would not persist state across function invocations or scale across multiple function app instances. Persisting counts in Table storage with ETags provides optimistic concurrency but doesn't guarantee the strong serialization of operations on a single item that Durable Entities offer, which is crucial for accurate inventory counts.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed