Courseiva

AZ-204 Practice Question: Connect to and consume Azure services and third-party services

Your Azure Function app processes messages from an Azure Service Bus queue. The function is triggered by Service Bus messages. Occasionally, the function throws an unhandled exception after the message is processed but before the function completes. What happens to the message?

⚠ Common exam trap

Many exam-takers assume an exception after processing still results in the message being completed or dead-lettered immediately, but Azure Functions' Service Bus trigger abandons the message for retry, not dead-lettering it on the first failure.

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

The message is abandoned and becomes available for other consumers after the lock duration expires.

In Azure Functions with a Service Bus trigger, the function runtime manages the lock on the message. If an unhandled exception occurs after the message has been processed but before the function returns, the runtime interprets this as a failure to complete the message. As a result, the message is abandoned, meaning the lock is released, and the message becomes available for redelivery to other consumers after the lock duration expires. This behavior ensures that messages are not lost but can be retried.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The message is moved to the dead-letter queue.

    Why it's wrong here

    When an Azure Function encounters an unhandled exception while processing a Service Bus message, the message is not immediately moved to the dead-letter queue. Instead, it is abandoned, and its delivery count is incremented. The message will only be moved to the dead-letter queue if its delivery count exceeds the `MaxDeliveryCount` configured for the queue or subscription, or if the function explicitly calls the `DeadLetter()` operation.

  • The message is abandoned and becomes available for other consumers after the lock duration expires.

    Why this is correct

    When an Azure Function processing a Service Bus message in PeekLock mode throws an unhandled exception, the underlying Service Bus message client implicitly calls `Abandon()` on the message. This action releases the lock on the message, making it available for other consumers to process once the message's `LockDuration` expires. The message's `DeliveryCount` is incremented, indicating it has been attempted and failed, thus preparing it for a retry.

  • The message is completed automatically despite the exception.

    Why it's wrong here

    Message completion (`Complete()`) signifies successful processing and permanently removes the message from the queue or subscription. An unhandled exception explicitly indicates that the processing was unsuccessful, preventing automatic completion. If the message were completed despite an exception, it would lead to data loss or incorrect state, as the failed operation would not be retried.

  • The message is automatically removed from the queue.

    Why it's wrong here

    An unhandled exception in an Azure Function does not cause the message to be automatically removed from the queue. Instead, the message is abandoned, which means its lock is released, and it becomes available again for processing after its lock duration expires. Automatic removal would imply permanent deletion, which would violate the reliable messaging principles of Azure Service Bus, especially for transient errors.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

One of 881 original AZ-204 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

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.