Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Implement event-driven scaling by using Kubernetes Event‑driven Autoscaling (KEDA) in Container Apps

A worked example

Complete the statement

You are deploying a background worker to Azure Container Apps. The worker reads messages from the inventory-updates queue in the Azure Storage account stecommerce.

Requirements:

  • When the queue is empty, the app must incur no compute charges.
  • No connection strings or access keys may be stored in the container app, including as Container Apps secrets.
  • The scaler must target 10 queued messages per replica.

A user-assigned managed identity already exists and has been granted the required permissions on the storage account.

How should you complete the Azure CLI command?

az containerapp create \
  --name inventory-worker \
  --resource-group rg-ecommerce \
  --environment my-environment \
  --image myregistry.azurecr.io/inventory-worker:v1 \
  --user-assigned <MANAGED_IDENTITY_RESOURCE_ID> \
  --min-replicas  \
  --max-replicas 20 \
  --scale-rule-name storage-queue-scaling \
  --scale-rule-type azure-queue \
  --scale-rule-metadata "accountName=stecommerce" \
                        "queueName=inventory-updates" \
                        "" \
   <MANAGED_IDENTITY_RESOURCE_ID>
  • Blank 1: 0 (correct answer)

    A minimum of 0 lets the event-driven rule scale the app to zero replicas when the queue is empty, so no compute charges are incurred. A minimum of 1 or 2 keeps replicas running while the queue is empty, and those replicas are still billed at the idle rate.

  • Blank 2: queueLength=10 (correct answer)

    queueLength is the azure-queue metadata parameter that sets the messages per replica that trigger scaling. messageCount is the Service Bus scaler's threshold. listLength is the Redis Lists threshold. lagThreshold is the Kafka consumer-lag threshold. None of these three apply to an Azure Storage queue.

  • Blank 3: --scale-rule-identity (correct answer)

    --scale-rule-identity tells the scaler to authenticate with the managed identity, so no connection string is stored. --scale-rule-auth maps a scaler parameter to a Container Apps secret, which would hold a connection string or key. --secrets stores secret values such as connection strings in the app. Both of these break the no-stored-credentials requirement.

Why

Event-driven rules support scale-to-zero, and an app at zero replicas incurs no compute charges, so the minimum must be 0. For an Azure Storage queue, the scaler threshold is set with queueLength, which is the number of messages per replica that triggers scaling. Passing the user-assigned managed identity to --scale-rule-identity lets the scaler authenticate without any connection-string secret. This meets the requirement that no credentials are stored in the app.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free