Azure Container Apps scale-to-zero for an empty Service Bus queue

AI-200 By islever Editorial Last updated

Short answer

BC Set the Container Apps scale rule to permit zero replicas and add a KEDA Azure Service Bus queue-length trigger so the service scales to zero when the queue is empty.

Question

You develop a message-processing service deployed to Azure Container Apps. The service reads messages from an Azure Service Bus queue. The solution must minimize costs by ensuring NO compute resources are consumed when the queue is empty. You need to configure scaling for the service. Which two actions should you perform? Each correct answer presents part of the solution.
  1. Increase the scaling rule to allow for the maximum running replica count.
  2. Configure the scaling rule to allow for the termination of all active replicas. Correct Answer
  3. Configure a Kubernetes Event-driven Autoscaler rule that monitors queue length. Correct Answer
  4. Enable HTTP ingress concurrency scaling.

Key Takeaways

Azure Container Apps scale-to-zero for Service Bus queues relies on a KEDA queue-length scaler plus a minimum replica count of zero. The correct combination is B and C: permit all replicas to terminate and monitor queue length, so an empty queue consumes no compute. A higher maximum replica count or HTTP concurrency scaling does not respond to queue depth and cannot satisfy the idle-cost requirement.

Expert Analysis

The idle-cost constraint is met only when the Service Bus queue itself is the scaling signal and the Container Apps revision is allowed to fall to zero replicas, which is why the configuration must pair a KEDA queue-length rule with permission to terminate every active replica.

Maximum-replica growth and HTTP concurrency both miss the Service Bus idle state

Option A raises the upper bound on replicas, so it affects how far the app can burst when the queue is deep; it leaves the floor at whatever the revision already uses, and a ceiling cannot remove the last warm replica during an empty queue. Option B sets that floor to zero, allowing KEDA to terminate all active replicas when the queue has no messages; without a trigger that can request replicas again, zero would be a dead end rather than a cost control. Option C supplies the needed trigger by watching the Service Bus queue length, so pending message count drives replica count up from zero and back down as the backlog clears. Option D points the scale rule at HTTP ingress concurrency, but queue messages do not create HTTP requests; the rule would measure the wrong signal, and any warm replica it maintains is pure idle cost for a queue-only workload. A and D are therefore not cost-saving actions, while B and C are complementary halves: the trigger identifies emptiness, and the minimum-replica setting lets the app act on it.

Zero-replica permission plus a KEDA queue-length trigger satisfies the billing constraint

The decisive property of this deployment is that all work arrives through an Azure Service Bus queue and the required idle state is an empty queue with no compute billing. Container Apps translates that requirement into two independent settings: the revision's minimum replica count and the KEDA scaler metadata. A Service Bus scaler configured with the queue name and a target message count polls the queue length; when the queue is empty, KEDA can request zero replicas. Setting minReplicas to 0 removes the platform's warm-replica floor and satisfies option B's termination of all active replicas. Neither setting works alone. A KEDA queue rule with a minimum of one leaves one replica running and billed while the queue is empty, which violates the no-compute condition. A zero minimum without a queue trigger may scale down but has no event source to scale back up, so the service cannot process the next message. The combination is what the cost constraint demands: queue length controls the desired count, and zero is a legal desired count. The maximum replica count remains a cap for backlog bursts; it is not part of the idle-cost calculation.

An HTTP-driven workload, not a queue-fed one, would justify concurrency scaling

Option D would become the right scaling rule if the service's unit of work were an inbound HTTP request and the idle definition were zero concurrent requests. In that design, HTTP ingress concurrency scaling could add replicas as request concurrency rises and, with a zero minimum, could release them when traffic stops. The condition is not met here because messages are pulled from a Service Bus queue; the arrival of a message does not create an HTTP request to the Container Apps ingress, so a concurrency rule sees no load even as the backlog grows. The queue is the event source, so an HTTP metric cannot distinguish an idle service from a backlogged one. Similarly, option A would matter only if the problem were insufficient burst capacity and the baseline already scaled to zero; the stated objective is idle cost, not peak throughput, so raising maxReplicas changes the ceiling without touching the empty-queue case. B and C remain tied to the actual event source. The HTTP rule is not merely less efficient; it is measuring a different resource and would leave the queue backlog invisible to the autoscaler.

Carry the event-source-plus-minimum-replica test to other Container Apps scaling decisions

For any Container Apps cost question, first identify the work source and the exact idle state, then check whether the scale rule observes that source and whether the revision is permitted to reach zero. Here the source is an Azure Service Bus queue, the idle state is an empty queue, and the rule is a KEDA Service Bus scaler; the permission is minReplicas: 0. The maximum replica count is a separate capacity control, and ingress concurrency is only relevant when HTTP requests are the work. A useful if-then check is: if the requirement says 'no compute when there is no work,' then the answer must include both a trigger that can report zero work and a minimum replica count of zero; if either is missing, the design either keeps a paid warm replica or cannot wake on the next event. Also verify that no other scale rule or revision setting imposes a floor. On exam items, reject any option that raises a ceiling, changes an HTTP concurrency target, or mentions replica termination without naming the event trigger that restores capacity.

Official Reference

https://learn.microsoft.com/en-us/azure/container-apps/scale-app

This link opens the official vendor documentation in a new tab.

Exam Strategy

For scale-to-zero items, separate the event source from the replica floor before evaluating any option. Ask which metric the scaler reads and which setting lets the revision reach zero; the correct pair usually names the source-specific scaler and a zero minimum. Options that adjust a maximum, use HTTP concurrency for a queue, or terminate replicas without a wake-up trigger are distractors. Verify that no other rule or ingress keeps one replica warm.

Practice All AI-200 Questions

Access 69 questions with complete answers and detailed explanations.

View Full AI-200 Practice Test →

← Back to AI-200 Study Guide