AZ-204 Practice Question: Connect to and consume Azure services and third-party services
You have an Azure Function that processes messages from an Event Hubs event stream. The function is failing with 'Message lock lost' errors. The processing time per event is about 10 minutes. What should you do to resolve the errors?
⚠ Common exam trap
Many candidates confuse function timeout with Event Hubs lease duration, assuming that extending the function's timeout will fix the lock loss, but the lease is managed independently by the EventProcessorHost and must be configured separately.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Configure the EventProcessorOptions with a longer lease duration
The 'Message lock lost' error occurs because the default Event Hubs lease duration (30 seconds) is too short for processing that takes 10 minutes per event. By configuring the EventProcessorOptions with a longer lease duration, you ensure the partition lease is not expired while the function is still processing the event, preventing the lease from being stolen by another instance.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Increase the function's timeout duration
Why it's wrong here
A function's timeout duration dictates the maximum time the Azure Functions host allows the function code to execute before terminating it. While a very long-running function could indirectly contribute to checkpointing issues if it never completes, increasing this timeout does not directly address the Event Hubs client's lease management for a partition. The problem of losing a lock is specifically related to the Event Hubs lease expiring, which is a separate configuration from the function's overall execution limit.
- ✓
Configure the EventProcessorOptions with a longer lease duration
Why this is correct
The Event Processor Host (EPH) or Event Hubs client library acquires a time-bound lease on an Event Hub partition to process events. If the processing of events from that partition takes longer than the configured lease duration, the lease can expire, allowing another consumer instance in the same consumer group to potentially claim ownership of the partition. By configuring `EventProcessorOptions` with a longer `LeaseDuration`, you extend the period the current processor has exclusive access, preventing the lock from being lost prematurely during extended processing operations.
- ✗
Increase the number of partitions in the Event Hub
Why it's wrong here
Increasing the number of partitions in an Event Hub primarily enhances the overall throughput and parallelism capabilities of the Event Hub. More partitions allow for a greater number of concurrent consumer instances to process events, but this configuration does not alter the lease duration or the mechanism by which a single consumer instance maintains its lock on a *specific* partition. The issue of losing a lock is tied to the processing time per partition exceeding its individual lease duration, not the total number of available partitions.
- ✗
Decrease the batch size to process events faster
Why it's wrong here
While decreasing the batch size might reduce the *cumulative time* required to process a single batch of events, it does not directly configure or extend the underlying lease duration for an Event Hub partition. The lease duration is a distinct setting within `EventProcessorOptions`. If the configured lease duration is inherently too short for the *expected maximum processing time* per lease renewal interval, even smaller batches could still lead to lock loss if processing is delayed by external factors or intermittent slowness.
Visual reference
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 881 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.