Question 264 of 881
AZ-204 Develop Azure compute solutions Practice Question
You deploy an Azure Function app that uses the Premium plan. The function processes messages from an Azure Service Bus queue. Under heavy load, some messages are processed multiple times. You need to ensure exactly-once processing without losing messages. What should you do?
⚠ Common exam trap
Watch out — candidates often confuse client-side idempotency (e.g., using a database unique constraint) with broker-level duplicate detection, or they mistakenly believe that Peek-Lock mode alone guarantees exactly-once processing, ignoring the risk of crashes after processing but before completion.
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
✓
Enable duplicate detection on the Service Bus queue.
Enabling duplicate detection on the Service Bus queue ensures that the Service Bus broker itself discards duplicate messages based on a user-defined time window. This prevents the function from processing the same message multiple times, even if the function host restarts or the message is re-delivered due to transient failures. Duplicate detection works by tracking the MessageId of each message and ignoring any subsequent message with the same MessageId within the detection window.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Enable duplicate detection on the Service Bus queue.
Why this is correct
Enabling duplicate detection on an Azure Service Bus queue is the primary mechanism to ensure exactly-once message processing. When activated, Service Bus stores a history of message IDs for a configurable time window, typically up to seven days. If a producer attempts to send a message with an MessageId that matches one already processed within that window, Service Bus automatically rejects the duplicate, preventing its delivery to consumers and thus ensuring that each unique message is processed only once.
- ✗
Use Peek-Lock mode instead of Receive and Delete.
Why it's wrong here
While Peek-Lock mode is crucial for reliable message processing, it does not inherently guarantee exactly-once processing in the context of duplicates. Peek-Lock ensures that a message is not removed from the queue until explicitly completed by the consumer, allowing for retries if the function crashes before completing processing. However, if the function processes the message successfully but crashes before sending the Complete() signal, the message will eventually become available again, potentially leading to duplicate processing if the consumer logic isn't idempotent or if the producer sent the message multiple times.
- ✗
Set the maxDeliveryCount to 1 on the queue.
Why it's wrong here
Setting maxDeliveryCount to 1 on the Service Bus queue dictates that a message will be moved to the dead-letter queue after its first failed delivery attempt. This prevents infinite retries for a problematic message and ensures quick identification of processing failures. However, this setting addresses message retry policy for individual delivery failures, not the prevention of duplicate messages originating from the producer or multiple successful deliveries of the same logical message due to system retries or idempotency issues.
- ✗
Reduce the batch size in the function host.json.
Why it's wrong here
Reducing the batch size in the host.json configuration for an Azure Function's Service Bus trigger controls how many messages are processed concurrently in a single batch by a function instance. This primarily impacts throughput, latency, and resource consumption, potentially reducing the number of messages processed per invocation. However, modifying the batch size has no direct bearing on preventing duplicate messages from being delivered or processed by the function, as it is a scaling parameter, not a deduplication mechanism.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 24, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.