Category: Cloud computing

Exam Prep Hub for AI-200: Developing AI Cloud Solutions on Azure

Welcome to the AI-200: Developing AI Cloud Solutions on Azure Exam Prep Hub!

Welcome to the one-stop hub with information for preparing for the AI-200: Developing AI Cloud Solutions on Azure certification exam. The content for this exam helps prepare you to be “responsible for contributing to all phases of implementing AI solutions on Azure, with an emphasis on back-end services and components. You’re also responsible for supporting all phases of the development lifecycle, including requirements gathering, design, development, deployment, security, and monitoring”.
Upon successful completion of the exam, you earn the Microsoft Certified: Azure AI Cloud Developer Associate certification.

This hub provides information directly here (topic-by-topic as outlined in the official study guide), links to a number of external resources, tips for preparing for the exam, practice tests, and section questions to help you prepare. Bookmark this page and use it as a guide to ensure that you are fully covering all relevant topics for the AI-200 exam and making use of as many of the resources available as possible.


Audience Profile (from Microsoft’s site)

As a candidate for this Microsoft Certification, you’re responsible for contributing to all phases of implementing AI solutions on Azure, with an emphasis on back-end services and components. You’re also responsible for supporting all phases of the development lifecycle, including requirements gathering, design, development, deployment, security, and monitoring.
You should be proficient in:
- Azure SDKs and third-party SDKs used in Azure.
- Azure data management services.
- Azure monitoring and troubleshooting.
- Azure messaging and eventing.
- Vector databases.
- Python programming.
- Implementing containerized applications on Azure.

Skills at a glance (as specified in the official study guide)

  • Develop containerized solutions on Azure (20–25%)
  • Develop AI solutions by using Azure data management services (25–30%)
  • Connect to and consume Azure services (20–25%)
  • Secure, monitor, troubleshoot Azure solutions (20–25%)

Topic-by-Topic Exam Content

[click a topic link to access the content and practice questions for that topic]

Develop containerized solutions on Azure (20–25%)

Implement container application hosting

Implement container-orchestrated solutions

Develop AI solutions by using Azure data management services (25–30%)

Develop AI solutions by using Azure Cosmos DB for NoSQL

Develop AI solutions by using Azure Database for PostgreSQL

Integrate Azure Managed Redis in AI solutions

Connect to and consume Azure services (20–25%)

Develop event- and message-based AI solutions

Develop and implement Azure Functions

Secure, monitor, and troubleshoot Azure solutions (20–25%)

Implement secure Azure solutions

Monitor and troubleshoot Azure solutions


AI-200 Practice Exams

AI-200 Practice Exam #1 (30 questions)

AI-200 Practice Exam #2 (30 questions)

AI-200 Practice Exam #3 (30 questions)

AI-200 Practice Exam #4 (30 questions)


Important AI-200 Resources

Link to the free, comprehensive, self-paced course on Microsoft Learn:

Develop AI cloud solutions on Azure

This course has 9 learning paths:

(1) Implement container application hosting on Azure

This learning path has 2 modules:
(i) Store and manage containers in Azure Container Registry
(ii) Deploy containers to Azure App Service

(2) Deploy and manage apps on Azure Container Apps

This learning path has 3 modules:
(i) Deploy containers to Azure Container Apps
(ii) Manage containers in Azure Container Apps
(iii) Scale containers in Azure Container Apps

(3) Deploy and monitor applications on Azure Kubernetes Service

This learning path has 3 modules:
(i) Deploy applications to Azure Kubernetes Service
(ii) Configure applications on Azure Kubernetes Service
(iii) Monitor and troubleshoot applications on Azure Kubernetes Service

(4) Develop AI solutions with Azure Cosmos DB for NoSQL

This learning path has 3 modules:
(i) Build queries for Azure Cosmos DB for NoSQL
(ii) Implement vector search on Azure Cosmos DB for NoSQL
(iii) Optimize query performance for Azure Cosmos DB for NoSQL

(5) Develop AI solutions with Azure Database for PostgreSQL

This learning path has 3 modules:
(i) Build and query with Azure Database for PostgreSQL
(ii) Implement vector search with Azure Database for PostgreSQL
(iii) Optimize vector search in Azure Database for PostgreSQL

(6) Enhance AI solutions with Azure Managed Redis

This learning path has 3 modules:
(i) Implement data operations in Azure Managed Redis
(ii) Implement event messaging with Azure Managed Redis
(iii) Implement vector storage in Azure Managed Redis

(7) Integrate backend services for AI solutions

This learning path has 3 modules:
(i) Queue and process AI operations with Azure Service Bus
(ii) Develop event-driven AI workflows with Azure Event Grid
(iii) Build serverless AI backends with Azure Functions

(8) Manage application secrets and configuration for AI solutions

This learning path has 2 modules:
(i) Manage application secrets with Azure Key Vault
(ii) Manage application settings with Azure App Configuration

(9) Observe and troubleshoot apps on Azure

This learning path has 2 modules:
(i) Instrument an app with OpenTelemetry
(ii) Analyze app telemetry with logs and metrics

Link to the certification page:

Link to the “Microsoft Certified: Azure AI Cloud Developer Associate” certification page.

Link to the study guide:

Link to the Study Guide for AI-200: Building Intelligent Applications.

A highly rated course on Udemy:

AI-200: Azure AI Cloud Developer Associate Exam Prep

YouTube Video Series

AI Cloud Developer AI-200 Series


Good luck to you passing the AI-200 Exam!
However, the more preparation you have, the less luck you will need. 🙂

Visit this post to see the list of all the certification preparation hubs available on The Data Community.

Queue and process back-end operations by using Azure Service Bus, including dead-letter queue handling, messages, topics, and subscriptions (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Connect to and consume Azure services (20–25%)
   --> Develop event- and message-based AI solutions
      --> Queue and process back-end operations by using Azure Service Bus, including dead-letter queue handling, messages, topics, and subscriptions


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

AI applications frequently perform operations that should not block a user’s request. Examples include processing documents, generating embeddings, running batch inference, sending notifications, executing long-running model operations, or enriching data.

Azure Service Bus provides reliable asynchronous messaging that allows application components to communicate without requiring them to be available or execute at the same time.

For the AI-200 exam, you should understand how to:

  • Use Service Bus queues for asynchronous point-to-point processing.
  • Use topics and subscriptions for publish/subscribe scenarios.
  • Design messages for AI workloads.
  • Process messages reliably.
  • Understand message settlement.
  • Use peek-lock processing.
  • Handle retries and poison messages.
  • Work with dead-letter queues (DLQs).
  • Understand message locks and delivery counts.
  • Choose between queues and topics based on application requirements.

The key architectural idea is decoupling.

Instead of:

AI application → immediately execute expensive operation

you can use:

AI application → Service Bus → worker → AI operation

This allows the producer and consumer to scale independently and protects downstream AI services from sudden workload spikes.


1. What Is Azure Service Bus?

Azure Service Bus is a fully managed enterprise message broker designed for reliable asynchronous communication between distributed applications.

A typical architecture might look like:

Client
|
v
AI API
|
v
Service Bus Queue
|
+------------------+
| |
v v
Worker 1 Worker 2
| |
+--------+---------+
|
v
AI Service

The API does not have to wait for the worker to finish.

Instead, it places a message onto the queue and can return a response indicating that the operation has been accepted.

The worker processes the message later.

This provides several important architectural benefits.

Temporal decoupling

The producer and consumer do not have to be running simultaneously.

A producer can place a message into the queue even when the consumer is temporarily unavailable.

Load leveling

Suppose an application normally receives 100 AI requests per minute but occasionally receives 5,000 requests per minute.

Rather than requiring the AI processing infrastructure to immediately handle all 5,000 requests, the application can place requests into a queue.

Workers can process the backlog at a sustainable rate.

Incoming requests
|
v
+----------------+
| Service Bus |
| Queue |
+----------------+
|
v
+----------------+
| AI Workers |
| 1 2 3 4 ... |
+----------------+

The queue acts as a buffer between the workload producer and the processing infrastructure.

Competing consumers

Multiple worker instances can consume messages from the same queue.

For example:

             +--> Worker 1
             |
Service Bus -+--> Worker 2
   Queue     |
             +--> Worker 3
             |
             +--> Worker 4

Each message is normally processed by only one competing consumer.

This allows the processing tier to scale horizontally.


2. Azure Service Bus Messaging Entities

The three primary messaging entities you need to understand are:

  1. Queues
  2. Topics
  3. Subscriptions

The most important distinction is:

EntityCommunication patternTypical use
QueuePoint-to-pointWork distribution
TopicPublish/subscribeBroadcasting events
SubscriptionReceiver attached to a topicIndependent consumers

3. Service Bus Queues

A queue is appropriate when a message represents a unit of work that should generally be processed by one consumer.

For example:

AI API
|
| Submit document-processing request
v
Service Bus Queue
|
+---- Worker A
|
+---- Worker B
|
+---- Worker C

Although multiple workers can listen to the same queue, a particular message is delivered to one competing consumer for processing.

Example

Suppose an application accepts uploaded documents and needs to:

  1. Extract text.
  2. Generate embeddings.
  3. Store vectors.
  4. Update a search index.

The web application could put this message onto a queue:

{
"operation": "process-document",
"documentId": "12345",
"blobUrl": "https://storage/.../document.pdf",
"model": "embedding-model",
"correlationId": "abc-123"
}

A worker receives the message and performs the processing.

This is preferable to making the user’s HTTP request wait for the entire AI pipeline.


4. Topics and Subscriptions

Queues are primarily for point-to-point processing.

Topics and subscriptions are designed for publish/subscribe scenarios.

A topic can have multiple subscriptions:

                 +--> Subscription A --> Consumer A
                 |
Publisher --> Topic
                 |
                 +--> Subscription B --> Consumer B
                 |
                 +--> Subscription C --> Consumer C

Each subscription can receive its own copy of a published message.

Example AI architecture

Imagine that a document is uploaded.

Several independent operations need to happen:

  • Generate embeddings.
  • Perform compliance analysis.
  • Extract metadata.
  • Notify an audit system.

A topic could be used:

                  +--> Embedding subscription
                  |
Document Event --> Topic
                  |
                  +--> Compliance subscription
                  |
                  +--> Metadata subscription
                  |
                  +--> Audit subscription

This is a classic fan-out architecture.


5. Queues vs. Topics

A common AI-200 exam scenario asks you to choose between a queue and a topic.

Use a queue when:

One processing path should handle each work item.

Use a topic with subscriptions when:

Multiple independent processing paths need to receive the event.

Example

Scenario A:

A document-processing request must be handled by one available worker.

Use: Queue.

Scenario B:

A document-created event must be independently consumed by the search, auditing, analytics, and notification systems.

Use: Topic with subscriptions.


6. Subscription Filters

Subscriptions can use rules and filters to determine which messages are delivered to a particular subscription.

For example, a topic might receive:

{
"eventType": "DocumentUploaded",
"department": "Finance"
}

A subscription could filter messages so that only Finance documents are delivered.

This allows a single topic to support multiple specialized consumers without requiring every consumer to receive every message.

This is particularly useful in event-driven AI architectures.


7. Designing Service Bus Messages for AI Workloads

A Service Bus message should generally contain the information necessary for a consumer to locate and process the work.

A useful AI message might contain:

{
"operation": "generate-summary",
"documentId": "98431",
"storageUri": "https://storage.example/document.pdf",
"model": "summary-model",
"priority": "normal",
"correlationId": "req-982734"
}

Important concepts include:

Message body

Contains the primary payload.

For AI applications, this might be JSON containing:

  • Operation name
  • Entity ID
  • Storage location
  • Model information
  • Processing parameters

Application properties

Application properties can contain metadata used for routing, correlation, filtering, or processing decisions.

Examples include:

  • eventType
  • tenantId
  • priority
  • correlationId
  • contentType

Message ID

A producer can assign a unique message ID.

This can be useful for duplicate detection and application-level idempotency.

Correlation ID

A correlation ID allows related operations to be tracked across distributed components.

For example:

HTTP request
|
| correlationId = ABC123
v
Service Bus
|
v
AI worker
|
v
Azure AI service

Logging the same correlation ID throughout the workflow makes troubleshooting considerably easier.


8. Avoid Putting Large AI Payloads Directly in Messages

AI workloads can involve large documents, images, audio files, or other payloads.

Instead of putting a large file directly into the Service Bus message, a common architecture is the claim-check pattern.

The large payload is stored separately, such as in Azure Blob Storage.

The Service Bus message contains a reference:

{
"documentId": "12345",
"blobUri": "https://storage.example/document.pdf",
"operation": "extract-text"
}

The consumer retrieves the payload from storage.

This keeps messages smaller and allows the messaging layer to focus on coordinating work rather than transporting large files.


9. Message Processing Modes

Service Bus provides different approaches for receiving messages.

The two important concepts for the AI-200 exam are:

  • Peek-lock
  • Receive-and-delete

10. Peek-Lock Mode

Peek-lock is generally the preferred mode when losing a message is unacceptable.

The processing model is approximately:

Receive message
|
v
Message is locked
|
v
Process message
|
v
Complete message

When the consumer receives a message in peek-lock mode, the message is temporarily locked so another consumer cannot simultaneously process it.

After successful processing, the consumer explicitly completes the message.


11. Message Settlement

When using peek-lock, the consumer must settle the message.

Important settlement operations include:

Complete

The operation succeeded.

The message is removed from the queue or subscription.

Process successfully
|
v
Complete
|
v
Message removed

Abandon

The consumer cannot successfully process the message and wants it made available again.

Processing failure
|
v
Abandon
|
v
Message becomes available again

Dead-letter

The message is considered unsuitable for normal processing and is moved to the dead-letter queue.

This is useful for poison messages or messages that cannot be successfully processed after repeated attempts.

Defer

The consumer can defer a message when processing cannot currently continue but the application wants to retrieve it later using its sequence number.


12. Why Peek-Lock Is Important

Consider this sequence:

1. Worker receives message.
2. Worker starts AI processing.
3. Worker crashes.
4. Message was never completed.

Because the message wasn’t completed, Service Bus can make it available again after the lock expires.

This provides an at-least-once processing behavior.

The important consequence is:

A message can potentially be processed more than once.

Therefore, AI workers should ideally be designed to be idempotent.

For example, before inserting an embedding, the application could check whether that document/version has already been processed.


13. Receive-and-Delete

In receive-and-delete mode, the message is removed as soon as it is received.

Receive
|
v
Message deleted
|
v
Process

This can provide simpler and potentially higher-throughput processing, but it introduces a major risk.

If the worker crashes after receiving the message but before completing the work, the message is already gone.

Therefore:

Use peek-lock when message loss is unacceptable.

Use receive-and-delete only when occasional message loss is acceptable.


14. Message Locks

When a message is received using peek-lock, it is temporarily locked.

The lock prevents another receiver from processing the same message simultaneously.

However, the lock has a limited duration.

If processing takes too long, the application can renew the lock where supported.

For long-running AI operations, this is important.

For example:

Receive
|
v
Lock acquired
|
+---- Process AI request
|
+---- Renew lock
|
+---- Renew lock
|
v
Complete

If the lock expires before the message is completed, the message can become available again.

This can result in duplicate processing.


15. Dead-Letter Queues

A dead-letter queue (DLQ) is a secondary subqueue associated with a Service Bus queue or topic subscription.

It stores messages that cannot be successfully processed or delivered.

Common causes include:

  • Exceeding the maximum delivery count.
  • Message expiration when dead-lettering on expiration is enabled.
  • Explicit application dead-lettering.
  • Certain forwarding or routing failures.
  • Invalid processing conditions.

The DLQ is therefore an important mechanism for handling poison messages.


16. What Is a Poison Message?

A poison message is a message that repeatedly fails processing.

For example:

Message received
|
v
AI worker fails
|
v
Message retried
|
v
AI worker fails
|
v
Message retried
|
v
...
|
v
Dead-letter queue

Without a DLQ, the same bad message could continuously consume processing capacity.


17. Maximum Delivery Count

Service Bus queues and topic subscriptions have a maximum delivery count.

The default value is commonly 10.

When a message is repeatedly delivered under peek-lock and the processing attempt fails—for example, because the message is abandoned or its lock expires—the delivery count increases.

Once the configured maximum is exceeded, Service Bus moves the message to the DLQ.

The important exam concept is:

Increasing the maximum delivery count does not fix a poison message. It only allows more failed delivery attempts before dead-lettering.

The appropriate value depends on the workload.


18. Handling the Dead-Letter Queue

A DLQ should not simply become a place where failed messages are forgotten.

A production application should monitor it.

A typical operational workflow is:

             Normal Queue
                  |
                  v
             AI Worker
                  |
             Processing
             /         \
          Success      Failure
             |           |
             v           v
          Complete      Retry
                         |
                         v
                    Max attempts
                         |
                         v
                       DLQ
                         |
                         v
                 Investigate
                         |
              +----------+----------+
              |                     |
           Correct                Reject
              |                     |
              v                     v
          Reprocess              Discard

The application or operations team can inspect DLQ messages, determine why processing failed, correct the underlying problem, and potentially resubmit appropriate messages.

Dead-lettered messages include dead-letter reason information that can help diagnose the failure.


19. Explicit Dead-Lettering

An application can explicitly dead-letter a message.

This is appropriate when the application determines that retrying will not solve the problem.

For example:

Message:
customerId = 123
operation = generate-report
format = "INVALID_FORMAT"

If the application knows that the message is permanently invalid, repeatedly retrying it is wasteful.

The worker can dead-letter the message instead.

This is different from a transient error such as:

AI service temporarily unavailable

A transient failure may justify retrying.

A permanently invalid message generally should not.


20. Retry vs. Dead-Letter

A useful exam distinction is:

SituationAppropriate response
Temporary network failureRetry
Temporary AI service throttlingRetry
Worker temporarily unavailableRetry
Invalid message structurePotentially dead-letter
Unsupported operationPotentially dead-letter
Poison messageDead-letter after appropriate retries
Processing repeatedly failsDead-letter
Successful processingComplete

The key is distinguishing transient failures from permanent failures.


21. Time to Live (TTL)

Messages can have a time-to-live (TTL).

TTL determines how long a message is considered valid.

For example:

Message created
|
|---------------- TTL ----------------|
| |
v v
Valid Expired

An expired message should generally no longer be processed.

If dead-lettering on message expiration is enabled for the entity, expired messages can be moved to the DLQ.

This can be useful when stale AI requests are no longer useful.

For example, an AI recommendation request that is several hours old may no longer have business value.


22. Idempotent AI Processing

At-least-once delivery means that duplicate processing is possible.

Consider:

Worker receives message
|
v
Generate embedding
|
v
Store embedding
|
X
Worker crashes before Complete

The message may be delivered again.

The worker might generate and store the embedding again.

A robust application should therefore make important operations idempotent.

One strategy is to use a deterministic identifier:

documentId + documentVersion

The worker can check whether that specific version has already been processed.

Another approach is to use Service Bus duplicate-detection capabilities where appropriate, combined with application-level safeguards.

Do not assume that messaging infrastructure alone eliminates every duplicate-processing scenario.


23. Sessions and Ordered Processing

Some applications require related messages to be processed in order.

Service Bus supports sessions for this purpose.

A session groups related messages using a session identifier.

For example:

Session: Customer-1001
Message 1
Message 2
Message 3
Message 4

A session-enabled consumer can process the messages associated with the session as an ordered sequence.

Sessions are useful when an AI workflow contains stateful or order-dependent operations.

For example:

Document uploaded
|
v
Text extracted
|
v
Embedding generated
|
v
Index updated

If later operations depend on earlier ones, ordering can become important.


24. Service Bus in an AI Architecture

A common AI architecture might look like:

                +----------------+
                | Client         |
                +-------+--------+
                        |
                        v
                +----------------+
                | AI API         |
                +-------+--------+
                        |
                        v
                +----------------+
                | Service Bus    |
                | Queue          |
                +-------+--------+
                        |
             +----------+----------+
             |          |          |
             v          v          v
          Worker 1   Worker 2   Worker 3
             |          |          |
             +----------+----------+
                        |
                        v
                +----------------+
                | Azure AI       |
                | Services       |
                +----------------+

This design provides:

  • Asynchronous processing.
  • Load leveling.
  • Horizontal scalability.
  • Failure isolation.
  • Retry capabilities.
  • Durable message storage.
  • Better control of downstream AI workloads.

25. Service Bus Topics in AI Event Architectures

Topics are especially useful when one AI event needs to trigger multiple independent workflows.

For example:

                    +--> Embedding pipeline
                    |
DocumentUploaded -->+--> Classification pipeline
                    |
                    +--> Audit pipeline
                    |
                    +--> Notification pipeline

Each pipeline can have its own subscription.

This avoids tightly coupling the document-uploading application to every downstream service.


26. Monitoring Service Bus Workloads

Operational monitoring is important because messaging problems can be difficult to see from the front-end application alone.

Useful indicators include:

  • Active message count.
  • Dead-letter message count.
  • Message processing failures.
  • Message age.
  • Processing latency.
  • Receiver throughput.
  • Queue backlog.
  • Delivery counts.

A growing active-message count can indicate that producers are generating messages faster than consumers can process them.

A growing DLQ count can indicate a processing or data-quality problem.

For AI workloads, also monitor downstream dependencies such as model-service throttling and latency.


27. Common AI-200 Exam Traps

Trap 1: Choosing a topic when only one worker should process each message

Use a queue for a competing-consumer workload.

Trap 2: Choosing a queue when multiple independent consumers need every event

Use a topic with subscriptions.

Trap 3: Assuming peek-lock means exactly-once processing

Peek-lock supports reliable processing, but duplicate processing can still occur.

Design consumers to be idempotent.

Trap 4: Using receive-and-delete for critical workloads

The message is removed before processing completes.

If the worker fails, the message can be lost.

Trap 5: Treating the DLQ as a retry queue

A DLQ is primarily a place to isolate messages that cannot be successfully processed or delivered.

Investigate the cause before reprocessing them.

Trap 6: Increasing MaxDeliveryCount to solve permanent failures

If the message itself is invalid, more retries simply waste resources.

Trap 7: Putting large documents directly into Service Bus messages

Consider storing large payloads in Blob Storage and placing a reference in the message.

Trap 8: Forgetting duplicate processing

At-least-once processing means consumers should tolerate duplicates.


28. Quick Decision Guide

Use this mental model for the exam:

Need asynchronous processing?
|
v
Azure Service Bus
|
+-----+------+
| |
One path Many paths
| |
v v
Queue Topic
|
v
Subscriptions

For message processing:

Critical message?
|
+---- Yes ---> Peek-lock
|
+---- No ----> Receive-and-delete may be acceptable

For processing failures:

Failure
|
+--> Temporary? ----> Retry
|
+--> Permanent? ----> Dead-letter
|
+--> Repeated failure? ----> DLQ

For large AI payloads:

Large file
|
v
Blob Storage
|
v
Service Bus message
(reference + metadata)

29. Key Takeaways

For AI-200, remember these concepts:

  1. Queues provide point-to-point messaging and competing-consumer processing.
  2. Topics provide publish/subscribe messaging.
  3. Subscriptions allow independent consumers to receive copies of topic messages.
  4. Peek-lock is appropriate when message loss is unacceptable.
  5. Receive-and-delete removes a message before processing completes and can result in message loss.
  6. Complete removes a successfully processed message.
  7. Abandon makes a message available for another delivery attempt.
  8. Dead-letter moves a message into the DLQ for isolation and investigation.
  9. At-least-once processing means duplicate processing is possible.
  10. AI workers should be designed to be idempotent where duplicate execution is possible.
  11. Maximum delivery count controls how many delivery attempts occur before dead-lettering.
  12. TTL controls message lifetime.
  13. Topics are ideal for fan-out scenarios.
  14. Subscription filters can selectively route messages.
  15. Correlation IDs are valuable for distributed tracing and troubleshooting.
  16. Large payloads should generally be stored externally, with a reference in the Service Bus message.
  17. Sessions can be used when ordered, stateful message processing is required.
  18. A growing DLQ is an operational signal that requires investigation.
  19. A growing active-message backlog can indicate insufficient consumer capacity.
  20. Service Bus is particularly valuable in AI architectures because it decouples request ingestion from potentially expensive or long-running AI processing.

Practice Exam Questions

Question 1

An AI application receives document-processing requests through an HTTP API. Each request should be processed by exactly one available worker. Multiple worker instances must be able to process requests concurrently.

Which Azure Service Bus entity should you use?

A. Queue

B. Topic with one subscription

C. Topic with multiple subscriptions

D. Event Grid topic

Answer: A. Queue

Explanation

A Service Bus queue is designed for point-to-point communication and competing consumers. Multiple workers can receive messages from the same queue while each message is processed by one consumer.

A topic is more appropriate when the same event needs to be delivered independently to multiple subscribers. Event Grid is primarily designed for event notification and event-driven architectures rather than work-queue semantics.


Question 2

An AI application publishes a DocumentUploaded event. Three independent services must receive the event: an embedding service, an auditing service, and a notification service.

Which Service Bus design should you use?

A. Three separate queues with the application sending the message to each queue

B. One queue with three competing consumers

C. One topic with three subscriptions

D. One subscription attached to three queues

Answer: C. One topic with three subscriptions

Explanation

A Service Bus topic with multiple subscriptions implements a publish/subscribe pattern. Each subscription can independently receive a copy of the event.

Using a queue with multiple competing consumers would not guarantee that all three services receive the message because competing consumers process a message rather than each receiving an independent copy.


Question 3

An AI worker receives a message using peek-lock mode. The worker successfully completes the AI operation but crashes before completing the Service Bus message.

What can happen?

A. The message is permanently deleted

B. The message can become available for redelivery

C. The message is automatically moved to another subscription

D. The message is converted into a scheduled message

Answer: B. The message can become available for redelivery

Explanation

With peek-lock, the message is not removed until the consumer successfully settles it, typically by completing it.

If the lock expires before completion, Service Bus can make the message available again. This creates the possibility of duplicate processing and is why consumers should be designed to be idempotent.


Question 4

An AI worker repeatedly receives a malformed message that cannot ever be processed successfully. The application should prevent the message from continually consuming worker capacity.

What is the most appropriate action?

A. Increase the message TTL

B. Dead-letter the message

C. Schedule the message for later

D. Extend the message lock indefinitely

Answer: B. Dead-letter the message

Explanation

A permanently invalid message is a good candidate for dead-lettering. The DLQ isolates the message from normal processing while allowing operators or application logic to investigate it.

Increasing retries or extending locks does not solve a permanent data problem.


Question 5

An AI application processes messages that occasionally fail because an external AI service is temporarily unavailable. What should the application generally do first?

A. Retry the operation

B. Immediately delete the message

C. Immediately dead-letter every message

D. Disable the Service Bus queue

Answer: A. Retry the operation

Explanation

A temporary service outage is a transient failure. Retrying the operation is generally appropriate, assuming the retry strategy is bounded and incorporates appropriate delay/backoff.

Permanent failures should generally be dead-lettered rather than repeatedly retried.


Question 6

An AI application uses Service Bus to process critical inference requests. The application must minimize the possibility of losing a request if a worker crashes while processing it.

Which receive mode should be used?

A. Receive-and-delete

B. Peek-lock

C. Browse-only

D. Scheduled delivery

Answer: B. Peek-lock

Explanation

Peek-lock allows the worker to receive and lock the message without immediately removing it. The worker completes the message after successful processing.

If the worker crashes before completion, the message can become available for redelivery after the lock expires.

Receive-and-delete removes the message as soon as it is received, so a worker failure can result in message loss.


Question 7

A document-processing AI solution needs to pass a 20-MB document to a background worker. The development team wants to avoid putting the entire document into the Service Bus message.

What is the best design?

A. Store the document in Blob Storage and place a reference to it in the Service Bus message

B. Convert the document to Base64 and place it directly in the message

C. Split the document into hundreds of unrelated messages

D. Store the document in the message’s correlation ID

Answer: A. Store the document in Blob Storage and place a reference to it in the Service Bus message

Explanation

The claim-check pattern is appropriate for large payloads. The document can be stored in Blob Storage while the Service Bus message contains the document identifier or URI plus relevant metadata.

This keeps the messaging layer focused on coordinating work rather than transporting large payloads.


Question 8

A Service Bus queue has a configured maximum delivery count of 10. A worker receives a message but repeatedly abandons it because processing fails.

What eventually happens when the message exceeds the configured delivery limit?

A. The message is automatically copied to every topic

B. The message is permanently deleted without any record

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

D. The message is automatically sent to Event Grid

Answer: C. The message is moved to the dead-letter queue

Explanation

When a message repeatedly fails processing and exceeds the configured maximum delivery count, Service Bus moves it to the DLQ.

The DLQ provides a separate location where the message can be investigated and, when appropriate, corrected and reprocessed.


Question 9

An AI system publishes messages describing uploaded documents. The application has separate consumers for compliance, analytics, and embedding generation. Each consumer should receive its own copy of applicable messages.

Which feature should the developer use to route only relevant messages to each consumer?

A. Queue sessions

B. Topic subscription filters

C. Message lock renewal

D. Receive-and-delete mode

Answer: B. Topic subscription filters

Explanation

Topic subscriptions can use filters to determine which messages are delivered to each subscription.

For example, a compliance subscription could receive only documents belonging to a particular business category while an embedding subscription receives all document events.


Question 10

An AI worker processes a message successfully and writes the result to a database. Before the worker completes the Service Bus message, it crashes. The message is subsequently delivered again.

What is the best way for the application to handle this possibility?

A. Assume Service Bus guarantees exactly-once application processing

B. Disable message retries

C. Design the processing operation to be idempotent

D. Use receive-and-delete mode

Answer: C. Design the processing operation to be idempotent

Explanation

Peek-lock processing provides reliable message handling but does not eliminate the possibility of duplicate processing. A worker can successfully perform its business operation and then fail before completing the Service Bus message.

The message may therefore be delivered again.

An idempotent application can safely recognize that the operation has already been performed—for example, by using a document ID and version as an idempotency key—rather than creating duplicate results.

Receive-and-delete would actually increase the risk of losing messages if the worker fails before completing its work.


This exam topic is especially worth mastering for AI-200 because exam scenarios often combine Service Bus + asynchronous AI processing + retries + competing consumers + DLQs rather than asking about those features in isolation.


Go to the AI-200 Exam Prep Hub main page

Implement Azure Managed Redis data operations, including caching, expiration, and invalidation (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop AI solutions by using Azure data management services (25–30%)
   --> Integrate Azure Managed Redis in AI solutions
      --> Implement Azure Managed Redis data operations, including caching, expiration, and invalidation


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Azure Managed Redis is a fully managed, in-memory data store based on Redis Enterprise. It provides high-throughput, low-latency access to frequently used application data and can be used to improve the performance and scalability of applications that otherwise depend heavily on backend databases or services.

For the AI-200: Developing AI Cloud Solutions on Azure exam, developers should understand how to implement Redis data operations and, in particular, how to use Redis for:

  • Caching frequently accessed data
  • Storing and retrieving key-value data
  • Setting expiration times on cached data
  • Removing or invalidating stale data
  • Implementing cache-aside patterns
  • Reducing database and backend-service load
  • Improving application responsiveness
  • Selecting appropriate Redis data structures
  • Designing cache keys appropriately
  • Handling cache misses
  • Understanding eviction versus expiration
  • Avoiding common Redis performance mistakes

Azure Managed Redis is generally best viewed as a high-performance cache or temporary data store, rather than the authoritative system of record. Applications should normally retain authoritative data in a durable backend such as Azure Database for PostgreSQL, Azure SQL Database, or Azure Cosmos DB.


1. Why Use Azure Managed Redis?

Traditional applications frequently retrieve data from databases or external services. Although these systems are designed for reliability and scalability, repeatedly retrieving the same information can introduce unnecessary:

  • Network traffic
  • Database CPU utilization
  • Query processing
  • Connection utilization
  • Application latency
  • Backend service load

Redis addresses this by keeping frequently accessed information in memory.

A simplified architecture looks like this:

Application
|
v
Azure Managed Redis
|
| Cache miss
v
Primary Database

When the requested information is already in Redis, the application can return it without querying the primary database.

This can dramatically reduce response times for frequently accessed information.

Common examples

Redis can be useful for caching:

  • Product information
  • User profiles
  • Configuration data
  • Frequently requested database queries
  • API responses
  • Session information
  • Authentication-related application state
  • Frequently accessed reference data
  • AI application results
  • Semantic-cache results
  • Embeddings and vectors

Azure Managed Redis supports data caching, session storage, messaging scenarios, and AI-oriented scenarios such as storing embeddings and implementing semantic caching.


2. The Cache-Aside Pattern

One of the most important caching patterns for the AI-200 exam is the cache-aside pattern, sometimes called lazy loading.

The application is responsible for checking Redis before querying the authoritative data source.

The basic process is:

1. Application receives request
|
v
2. Look for data in Redis
|
+--+--+
| |
Hit Miss
| |
v v
Return Query
data database
|
v
Store result
in Redis
|
v
Return result

Cache hit

A cache hit occurs when the requested data is already in Redis.

Application → Redis → Data returned

The database does not need to be queried.

Cache miss

A cache miss occurs when the requested data isn’t present in Redis.

The application:

  1. Queries the authoritative database.
  2. Receives the result.
  3. Stores the result in Redis.
  4. Returns the result to the caller.

This pattern allows the cache to populate naturally based on actual application usage.

Conceptual pseudocode

value = Redis.GET(key)
IF value exists:
return value
value = Database.Query(...)
Redis.SET(key, value, expiration)
return value

The important principle is that Redis is populated when the application needs the data, rather than loading the entire database into memory.


3. Why Cache-Aside Is Particularly Useful

Suppose an application has one million customer records but only 20,000 customers access the application regularly.

Loading all one million records into Redis may waste memory.

With cache-aside:

  • Frequently accessed records enter the cache.
  • Infrequently accessed records remain in the database.
  • Expired records can be removed.
  • Redis memory is focused on valuable data.

This makes the cache more efficient.

Azure’s guidance specifically identifies cache-aside as a common data-cache pattern in which data is loaded into the cache only when needed.


4. Redis Key-Value Operations

At its simplest, Redis stores data using keys and values.

For example:

Key:
customer:12345
Value:
{"id":12345,"name":"Norm","tier":"Gold"}

The application can retrieve the value using the key.

Conceptually:

SET customer:12345 {...}
GET customer:12345

A good Redis key should:

  • Be unique within the application’s namespace
  • Be predictable
  • Be easy to construct
  • Identify the cached resource clearly
  • Avoid unnecessary length
  • Avoid collisions between unrelated data

A useful naming convention might be:

customer:12345
product:9876
order:54321
embedding:document:123

For larger applications, namespaces can make keys easier to manage:

customer:profile:12345
product:details:9876
ai:response:abc123

5. Choosing Redis Data Structures

Redis supports more than simple strings.

Common data structures include:

Data StructureTypical Use
StringSimple values, JSON, counters
HashObjects with multiple fields
ListOrdered collections or queues
SetUnique unordered values
Sorted SetRanked or scored collections
StreamEvent/message processing
Vector-related structuresAI embeddings and similarity scenarios

For ordinary application caching, strings and hashes are particularly common.

For example, a customer object might be stored as a JSON string:

customer:12345
|
+-- {"id":12345,"name":"Norm","status":"Active"}

Alternatively, a Redis hash could store individual fields:

customer:12345
name → Norm
status → Active
tier → Gold

The appropriate choice depends on how the application reads and updates the data.


6. Cache Expiration

Caching introduces an important problem:

What happens when the cached value becomes stale?

Redis provides key expiration, also called a time-to-live or TTL.

For example:

customer:12345
TTL = 300 seconds

After the expiration period passes, Redis automatically removes the key.

Azure Managed Redis supports setting timeouts on keys, and expired keys are automatically removed when their configured timeout passes.


7. Why Expiration Matters

Consider an application that caches weather information.

Suppose:

weather:orlando
TTL = 5 minutes

If the weather changes, the cached information should eventually disappear so that a subsequent request retrieves fresh information.

Without expiration, stale data could remain indefinitely.

Expiration therefore provides a simple mechanism for balancing:

  • Performance
  • Memory usage
  • Data freshness

8. Choosing an Appropriate TTL

The correct TTL depends on how quickly the underlying data changes.

Short TTL

Use a short expiration time when data changes frequently.

Examples:

stock price → seconds
real-time availability → seconds/minutes
weather → minutes

Medium TTL

Useful for data that changes periodically.

Examples:

product catalog → minutes/hours
exchange rates → minutes
application configuration → minutes

Long TTL

Useful for relatively stable data.

Examples:

reference data → hours
static metadata → hours/days

There is no universally correct TTL.

The developer should consider:

  • How frequently the source data changes
  • How stale the application can tolerate the data being
  • How expensive the source query is
  • How much Redis memory is available
  • How frequently the cached value is requested

9. Expiration Versus Deletion

Expiration and explicit deletion are related but different.

Expiration

The application specifies a timeout.

SET product:123 value
EXPIRE product:123 300

Redis eventually removes the key automatically.

Explicit deletion

The application deliberately removes the key.

Conceptually:

DEL product:123

This is useful when the underlying data changes and the application knows that the cached copy is no longer valid.

Azure Managed Redis identifies expiration, eviction, and explicit deletion as distinct reasons that cached keys can disappear.


10. Cache Invalidation

Cache invalidation means removing or updating cached data when it is no longer valid.

A classic example is updating a customer record.

Suppose the database contains:

Customer 123
Status = Active

Redis contains:

customer:123
Status = Active

The application changes the database:

Status = Suspended

If Redis still contains the old value, the application could continue returning:

Status = Active

The cache is now stale.

The application therefore needs an invalidation strategy.


11. Common Cache Invalidation Strategies

There are several common approaches.

Strategy 1: Delete the cache entry

After changing the authoritative database:

UPDATE database
DEL customer:123

The next request becomes a cache miss.

The application retrieves the current value from the database and repopulates Redis.

This is often a simple and effective approach.


Strategy 2: Update the cache

Instead of deleting the cache entry, the application updates Redis with the new value.

UPDATE database
SET customer:123 = new value

The advantage is that subsequent requests can immediately use the updated cache.

The disadvantage is that the application must carefully keep the database and cache synchronized.


Strategy 3: Rely on expiration

The application allows the cached value to expire naturally.

This is simpler but potentially allows stale data to remain available until the TTL expires.

For example:

TTL = 10 minutes

A database update occurring immediately after the cache was populated could result in stale data being served for almost 10 minutes.

Therefore, expiration alone may not be sufficient when data freshness is important.


12. Combining Invalidation and Expiration

A strong caching strategy often combines explicit invalidation with TTL.

For example:

Cache customer data
TTL = 30 minutes

When the customer changes:

UPDATE database
DELETE Redis key

The TTL provides protection against stale data if the invalidation process fails, while explicit invalidation removes known-stale data immediately.

This gives the application two levels of protection:

Normal update
|
v
Explicit invalidation
|
v
Immediate freshness
Unexpected missed invalidation
|
v
TTL expiration
|
v
Eventual freshness

This is an important architectural pattern to recognize in exam scenarios.


13. Cache Invalidation and the Source of Truth

A fundamental rule is:

The cache should generally not become the authoritative source of application data.

For example:

Azure Database for PostgreSQL
|
| authoritative data
v
Azure Managed Redis
|
| cached copy
v
Application

If Redis is lost, the application should be capable of rebuilding its cache from the authoritative data source.

Azure Managed Redis is designed primarily as a cache and temporary data store rather than a primary database.


14. Handling Cache Misses

Applications must always be designed to handle cache misses.

A cache miss is not necessarily an error.

It is an expected condition.

A typical workflow is:

GET key
|
+-- Found → return value
|
+-- Not found
|
v
Query database
|
v
Store in Redis
|
v
Return value

A well-designed application should therefore never assume:

“If the value isn’t in Redis, something is broken.”

Instead:

“If the value isn’t in Redis, retrieve it from the authoritative source.”


15. Cache Stampede

A cache stampede occurs when a frequently accessed cache entry expires and many requests simultaneously attempt to rebuild it.

For example:

Popular key expires
|
+-- Request 1 → Database
+-- Request 2 → Database
+-- Request 3 → Database
+-- Request 4 → Database
+-- ...
+-- Request 10,000 → Database

The cache was supposed to reduce database traffic, but expiration temporarily creates a massive burst of database requests.

Potential strategies include:

  • Staggering expiration times
  • Using appropriate TTLs
  • Refreshing hot data before expiration
  • Coordinating cache regeneration
  • Using locking or request coalescing techniques
  • Using a background refresh strategy

The exact implementation depends on application requirements.


16. Avoiding the “Thundering Herd”

A related problem is the thundering herd effect.

Suppose thousands of requests need the same data and the cache expires.

If every request independently queries the database, the backend can become overloaded.

A common mitigation is to allow one process to refresh the data while other requests wait briefly or use the previous value where appropriate.

Conceptually:

                Cache miss
                    |
            +-------+-------+
            |               |
        First request    Other requests
            |               |
        Refresh cache    Wait/use fallback
            |
            v
        New cached value

The goal is to prevent thousands of identical backend queries.


17. Cache-Aside Write Pattern

There are multiple ways to handle writes with a cache-aside architecture.

One common approach is:

1. Update database
2. Delete corresponding Redis key

For example:

UPDATE products
SET price = 25.00
WHERE product_id = 100;
DEL product:100;

The next read retrieves the new database value and caches it.

This pattern is attractive because the database remains the source of truth.


18. Why Delete-After-Write Is Often Safer Than Cache-First Updates

Consider:

Application
|
+--> Redis
|
+--> Database

If the application updates Redis first and the database update subsequently fails, the cache could contain a value that doesn’t exist in the database.

By updating the authoritative store first and invalidating the cache afterward, the application reduces this risk.

A typical sequence is:

Database update
|
v
Cache invalidation
|
v
Next request repopulates cache

The exact transaction and failure-handling strategy should be designed according to the application’s consistency requirements.


19. Expiration Does Not Mean Eviction

This is an important exam distinction.

Expiration

A key reaches its configured TTL.

TTL reaches zero
Key expires

Eviction

Redis needs to free memory and removes keys according to its configured memory/eviction behavior.

Memory pressure
Eviction policy
Keys removed

Explicit deletion

The application deliberately removes a key.

DEL key
Key removed

These are three different mechanisms.

Azure Managed Redis documentation identifies expiration, eviction, and explicit deletion as separate causes of keys disappearing from the cache.


20. Eviction and Memory Pressure

Redis is an in-memory service, so memory management is critical.

If the cache approaches its memory capacity, Redis can remove keys according to its configured eviction behavior.

Therefore, an application should not interpret every missing key as an expiration event.

Possible causes include:

  1. TTL expiration
  2. Memory eviction
  3. Explicit deletion
  4. Cache flushing
  5. Failover/replication behavior
  6. Other infrastructure-related events

Monitoring cache metrics can help distinguish these scenarios.


21. Key Naming Best Practices

A good key strategy makes a Redis implementation easier to maintain.

Consider:

customer:12345

instead of:

12345

The first provides context.

For a larger application:

customer:profile:12345
customer:orders:12345
customer:preferences:12345

This makes it easier to understand what each key represents.

Avoid unnecessarily large keys because Redis is optimized for high-performance operations and memory usage matters.


22. Avoid Storing Excessively Large Values

Redis is designed for fast in-memory access.

Large values can:

  • Consume significant memory
  • Increase network traffic
  • Increase serialization/deserialization costs
  • Increase latency
  • Reduce cache efficiency

For example, rather than caching a massive database object containing thousands of unnecessary fields, cache only the information needed by the application.

A useful principle is:

Cache what the application needs, not everything the database can provide.

Azure’s current guidance also recommends avoiding unnecessarily large Redis values because smaller values generally provide better performance characteristics.


23. Connection Management

Applications should avoid creating a new Redis connection for every request.

For example, this is generally a poor pattern:

Request 1 → Create connection → Redis → Close
Request 2 → Create connection → Redis → Close
Request 3 → Create connection → Redis → Close

Instead, applications should generally use a long-lived connection/client that can be reused across requests.

For .NET applications using StackExchange.Redis, Microsoft recommends a single long-lived ConnectionMultiplexer rather than creating a new connection for each request.

This reduces:

  • Connection overhead
  • Resource consumption
  • Latency
  • Connection churn

24. Connection Resilience

Applications should also assume that Redis connections can occasionally experience interruptions because of:

  • Maintenance
  • Failover
  • Network problems
  • Infrastructure events

The application should be designed to reconnect and handle transient failures appropriately.

For example:

Application
|
v
Redis connection
|
failure
|
v
Reconnect
|
v
Continue processing

For a cache, a Redis outage should ideally degrade application performance rather than completely destroy application functionality.

The application can fall back to the authoritative database when appropriate.


25. Redis as a Performance Layer

A useful way to conceptualize Azure Managed Redis is as a performance layer:

                +----------------+
                |   Application  |
                +-------+--------+
                        |
                        v
                +---------------+
                | Azure Managed |
                |     Redis     |
                +-------+-------+
                        |
                  Cache miss
                        |
                        v
                +---------------+
                |   Database    |
                +---------------+

The application gets:

  • Fast reads from Redis
  • Durable storage from the database
  • Reduced database workload
  • Better scalability

This separation is central to effective caching architecture.


26. Caching AI Application Data

Azure Managed Redis is particularly relevant to AI applications.

Possible cached information includes:

  • Embeddings
  • Frequently retrieved documents
  • AI-generated responses
  • Prompt-related information
  • Semantic-cache entries
  • User session state
  • Frequently accessed metadata

For example, a semantic cache might store:

Question:
"What is our vacation policy?"
Embedding / semantic representation
|
v
Redis
|
v
Previously generated answer

If another request is sufficiently similar, the application may reuse an existing result rather than repeatedly invoking an AI model.

This can reduce:

  • Model calls
  • Latency
  • Cost
  • Backend processing

Azure Managed Redis specifically supports AI scenarios such as vector storage and semantic caching.


27. Caching Versus Persistent Storage

A common exam trap is assuming that Redis should replace the database.

Generally:

RequirementBetter Choice
Authoritative relational dataPostgreSQL
Durable transactional dataPostgreSQL
Large persistent document storeCosmos DB or other durable storage
Frequently accessed temporary dataRedis
Session stateRedis
Short-lived application cacheRedis
Semantic cacheRedis
Embedding/vector workloadsRedis or specialized vector-capable data service

Redis should generally complement rather than replace the authoritative data store.


28. Cache Invalidation Strategies Compared

StrategyAdvantageDisadvantage
TTL expirationSimpleData can remain stale until TTL expires
Explicit deletionImmediate invalidationApplication must know when data changes
Update cacheFresh cache immediatelyMore synchronization complexity
TTL + deletionStrong balanceRequires both mechanisms
Background refreshGood for hot dataMore application complexity

For many applications, TTL plus explicit invalidation is an effective design.


29. Common Exam Scenario

Suppose an application retrieves product information from Azure Database for PostgreSQL.

The application receives thousands of requests for the same product.

The best architecture is:

Request
|
v
Redis GET product:123
|
+---- Hit ----> Return cached product
|
+---- Miss
|
v
Query PostgreSQL
|
v
Store in Redis with TTL
|
v
Return

When the product changes:

Update PostgreSQL
|
v
Delete product:123 from Redis

The next request retrieves the current value and repopulates the cache.

This is a classic cache-aside implementation.


30. Common Mistakes to Avoid

Mistake 1: Treating Redis as the primary database

Redis should generally be treated as a cache or temporary store, not the authoritative system of record.

Mistake 2: Never setting expiration

Without expiration, stale data can remain indefinitely and memory consumption can increase.

Mistake 3: Relying only on expiration

If freshness is important, explicit invalidation may be necessary.

Mistake 4: Confusing expiration with eviction

Expiration happens because a TTL expires.

Eviction happens because Redis needs memory and removes keys according to its configured policy.

Mistake 5: Creating a connection for every request

Reuse long-lived Redis connections/clients.

Mistake 6: Caching enormous objects

Large values increase memory and network costs.

Mistake 7: Ignoring cache misses

A cache miss should be an expected application path.

Mistake 8: Updating the cache without considering database consistency

The authoritative data store and cache must be handled carefully during writes.

Mistake 9: Assuming cached data is permanent

Redis is an in-memory service. Applications should be designed to tolerate cache loss and rebuild cached information when necessary.


31. AI-200 Exam Takeaways

For the AI-200 exam, remember these core concepts:

Cache-aside

Check Redis → if miss, retrieve from database → store in Redis → return data.

Expiration

A TTL automatically removes a key after the configured timeout.

Invalidation

Explicitly remove or update cached data when the authoritative data changes.

Eviction

Redis removes keys because of memory pressure according to its configured eviction behavior.

Source of truth

Keep authoritative data in a durable backend.

Connection management

Reuse long-lived Redis client connections rather than creating connections for every request.

Performance

Keep cached values reasonably small and avoid unnecessarily expensive Redis operations.

Resilience

Design the application to tolerate Redis connection failures and cache misses.

AI scenarios

Redis can support semantic caching, embedding/vector storage, session state, and other high-performance AI application patterns.


Practice Exam Questions

Question 1

An application retrieves product information from Azure Database for PostgreSQL. The same products are requested thousands of times per minute. The developer wants to reduce database load while keeping PostgreSQL as the authoritative data source.

Which approach should the developer implement?

A. Store all PostgreSQL tables permanently in Redis and stop using PostgreSQL for reads.

B. Use a cache-aside pattern in which the application checks Redis first and retrieves data from PostgreSQL on a cache miss.

C. Write every PostgreSQL transaction directly to Redis and use Redis as the primary database.

D. Query PostgreSQL for every request and use Redis only for logging.

Answer: B

Explanation:
The cache-aside pattern checks Redis first. On a cache miss, the application queries PostgreSQL, stores the result in Redis, and returns it. PostgreSQL remains the authoritative data source. This reduces repeated database queries while preserving the database as the system of record.


Question 2

An application caches weather information in Azure Managed Redis. Weather information should never remain in the cache for more than five minutes.

What should the developer configure?

A. A Redis key expiration of five minutes.

B. A five-minute Redis connection timeout.

C. A five-minute eviction policy.

D. A five-minute database transaction timeout.

Answer: A

Explanation:
Key expiration uses a TTL to automatically remove a key after a specified period. A five-minute TTL ensures the cached weather information does not remain cached beyond the configured lifetime. Expiration is different from eviction, which occurs because of memory pressure.


Question 3

A customer record is stored in both PostgreSQL and Redis. The customer updates their address. The application successfully updates PostgreSQL but the old address remains in Redis.

What is the best way to ensure the next read retrieves the current address?

A. Increase the Redis memory allocation.

B. Restart the Redis instance.

C. Delete the cached customer key after successfully updating PostgreSQL.

D. Disable Redis expiration.

Answer: C

Explanation:
Deleting the cached key explicitly invalidates the stale value. The next request causes a cache miss, retrieves the current customer record from PostgreSQL, and can repopulate Redis.


Question 4

A developer notices that Redis keys are disappearing before their expected TTL values are reached. The Redis instance is experiencing high memory utilization.

What is the most likely explanation?

A. PostgreSQL automatically deleted the Redis keys.

B. The Redis connection expired.

C. The application’s DNS record changed.

D. Redis evicted keys because of memory pressure.

Answer: D

Explanation:
Expiration and eviction are different. A key can be removed because its TTL expires, but Redis can also remove keys when memory pressure requires space to be reclaimed according to the configured eviction behavior.


Question 5

A web application creates a new Redis connection every time an HTTP request needs to retrieve cached data.

What should the developer generally do instead?

A. Use a single long-lived Redis client/connection that can be reused across requests.

B. Create two Redis connections for every request to provide redundancy.

C. Disable connection reuse so that every request receives a fresh connection.

D. Store Redis connection objects in every cached value.

Answer: A

Explanation:
Creating connections repeatedly introduces unnecessary overhead and connection churn. Redis applications should generally reuse long-lived client connections. For example, .NET applications using StackExchange.Redis commonly use a shared, long-lived ConnectionMultiplexer.


Question 6

A developer wants cached customer information to remain available for up to one hour but also wants changes to a customer record to become visible immediately.

Which strategy is most appropriate?

A. Use a one-hour TTL and never invalidate the cache.

B. Disable expiration and update Redis once per day.

C. Use a one-hour TTL and explicitly invalidate the customer’s cache entry when the database record changes.

D. Store the customer only in Redis and remove the PostgreSQL record.

Answer: C

Explanation:
Combining TTL with explicit invalidation provides two layers of protection. Explicit invalidation removes known-stale data immediately, while the TTL prevents an entry from remaining cached indefinitely if an invalidation event is missed.


Question 7

Thousands of users request the same product. The product’s Redis entry expires at nearly the same time, causing thousands of requests to query PostgreSQL simultaneously.

What problem does this scenario represent?

A. Cache encryption failure.

B. Cache stampede or thundering herd.

C. Redis key collision.

D. Database normalization.

Answer: B

Explanation:
A cache stampede occurs when a popular cached item expires and many requests simultaneously attempt to rebuild the cache. This can overwhelm the backend database. Techniques such as request coordination, locking, staggered expiration, and background refresh can reduce the problem.


Question 8

An application stores the following information in Redis:

customer:12345
customer:12346
customer:12347

What is the primary benefit of this naming convention?

A. It automatically encrypts the values.

B. It prevents Redis from expiring the keys.

C. It increases the Redis memory limit.

D. It provides a predictable namespace that identifies the type and identity of the cached resource.

Answer: D

Explanation:
A structured naming convention makes keys predictable, understandable, and easier to manage. Prefixes such as customer: distinguish customer records from other application data.


Question 9

An AI application frequently receives semantically similar questions. Generating a response for every request requires an expensive model invocation.

How could Azure Managed Redis help?

A. Cache previously generated results or semantic representations so suitable requests can reuse existing results.

B. Replace the AI model with Redis commands.

C. Store all model training data exclusively in Redis.

D. Use Redis expiration to permanently store every model response.

Answer: A

Explanation:
Azure Managed Redis can support semantic caching and AI workloads. An application can cache suitable AI responses or related representations and reuse them when a later request is sufficiently similar. This can reduce model calls, latency, and cost.


Question 10

A developer is designing an application that uses Redis for caching. The developer wants the application to continue functioning if cached data disappears.

Which design is most appropriate?

A. Treat Redis as the only authoritative copy of the data.

B. Disable all Redis expiration and eviction mechanisms.

C. Keep authoritative data in a durable database and design the application to repopulate Redis after cache misses.

D. Write all application data to Redis and periodically delete the database.

Answer: C

Explanation:
A resilient caching architecture treats Redis as a performance layer rather than the authoritative data store. If a cached item disappears because of expiration, eviction, deletion, or another event, the application can retrieve the authoritative value from the durable database and repopulate the cache.


Final Study Summary

For the AI-200 exam, the most important distinction is between the authoritative data store and the cache.

A typical architecture is:

                    Application
                         |
                         v
                 Azure Managed Redis
                    /           \
                 Hit             Miss
                  |                |
                  v                v
              Return          Query database
                                 |
                                 v
                           Populate Redis
                                 |
                                 v
                              Return

When data changes:

Update authoritative database
|
v
Invalidate Redis entry
|
v
Next request repopulates cache

And when a TTL expires:

TTL reaches zero
|
v
Key expires
|
v
Next request causes cache miss
|
v
Retrieve fresh data

Keep these concepts distinct:

ConceptMeaning
Cache hitRequested data exists in Redis
Cache missRequested data isn’t in Redis
TTLAmount of time a key is allowed to remain cached
ExpirationAutomatic removal after TTL expires
InvalidationApplication-driven removal/update of stale data
EvictionRemoval caused by memory pressure and eviction policy
Cache-asideApplication checks cache, then authoritative store on a miss
Cache stampedeMany requests rebuild an expired cache entry simultaneously
Source of truthDurable system containing authoritative data
Semantic cacheCache that can reuse results for sufficiently similar AI requests

The exam-ready mental model is simple:

Cache for speed, expire for freshness, invalidate when you know data changed, and keep the database as the source of truth.


Go to the AI-200 Exam Prep Hub main page

Store and retrieve embeddings and execute vector similarity search for semantic retrieval (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop AI solutions by using Azure data management services (25–30%)
   --> Develop AI solutions by using Azure Cosmos DB for NoSQL
      --> Store and retrieve embeddings and execute vector similarity search for semantic retrieval


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Modern AI applications frequently need to retrieve information based on meaning, rather than simply matching exact words.

For example, suppose a user asks:

“What options are available for taking my dog on vacation?”

A traditional keyword search might look for documents containing the words dog, vacation, or travel. A semantic search system can instead identify documents discussing pet-friendly hotels, even if those documents never use the exact words in the user’s question.

This is accomplished using vector embeddings and vector similarity search.

Azure Cosmos DB for NoSQL provides integrated vector storage, indexing, and search capabilities. Applications can store embeddings directly alongside their source documents and use the VectorDistance() system function to find documents whose vectors are closest to a query vector.

For the AI-200 exam, you should understand:

  • What embeddings are
  • How embeddings are generated
  • How embeddings are stored in Cosmos DB
  • Vector embedding policies
  • Vector indexing policies
  • flat, quantizedFlat, and diskANN
  • The VectorDistance() function
  • k-nearest-neighbor (kNN) searches
  • Semantic retrieval
  • Filtering vector searches
  • Why TOP N is important
  • How vector search fits into RAG applications
  • Important vector-search limitations

1. What Is a Vector Embedding?

A vector embedding is a numerical representation of information.

An embedding model converts content such as:

  • Text
  • Documents
  • Images
  • Audio
  • Other supported data

into an array of numerical values.

For example, a simplified embedding might look like:

[0.12, -0.43, 0.87, 0.21, -0.09]

Real-world embedding models generally produce vectors with many more dimensions.

The important concept is that the position of an embedding in a high-dimensional mathematical space represents characteristics of the original content.

Content with similar meanings tends to have vectors that are close together.

For example:

"How can I travel with my dog?"

might be semantically close to:

"Hotels that allow pets"

even though the two sentences don’t contain the same words.


2. Embeddings Are Generated Outside Cosmos DB

Azure Cosmos DB stores and searches embeddings, but the embedding itself is typically generated by an embedding model.

For example, an application might use an embedding API such as an Azure OpenAI embedding model.

The general workflow is:

Source content
|
v
Embedding model
|
v
Vector embedding
|
v
Azure Cosmos DB

For a search request:

User query
|
v
Embedding model
|
v
Query embedding
|
v
Cosmos DB vector search
|
v
Most semantically similar documents

The stored document embedding and query embedding need to be compatible. In practice, applications should generate both using the same embedding model or a compatible embedding space.


3. Storing Embeddings in Cosmos DB

One of the major advantages of the integrated vector capabilities in Azure Cosmos DB for NoSQL is that the embedding can be stored alongside the original document.

For example:

{
"id": "doc001",
"category": "travel",
"title": "Pet-Friendly Hotels",
"content": "Hotels that welcome dogs and cats...",
"embedding": [
0.123,
-0.456,
0.789,
0.234
]
}

The application therefore doesn’t need to maintain a completely separate database containing the vector and another database containing the associated document.

The vector and its source data can be colocated.

This is particularly useful for AI applications because the application can retrieve both:

  1. The similarity result
  2. The original content needed to answer the user’s question

from the same Cosmos DB item.


4. What Is Semantic Retrieval?

Semantic retrieval means finding information based on its meaning rather than simply matching keywords.

Consider these two documents:

Document A

“Our resort provides accommodations for guests traveling with pets.”

Document B

“Our resort has a swimming pool and fitness center.”

A user searches:

“Where can I stay with my dog?”

Document A is likely to have a much closer semantic relationship to the query.

A vector search system identifies that relationship by comparing embeddings.

The basic process is:

  1. Generate embeddings for documents.
  2. Store the embeddings with the documents.
  3. Generate an embedding for the user’s query.
  4. Compare the query vector with document vectors.
  5. Rank documents according to similarity.
  6. Return the most relevant documents.

This is the foundation of many retrieval-augmented generation (RAG) applications.


5. Vector Search in Azure Cosmos DB

Azure Cosmos DB for NoSQL provides vector search capabilities through:

  • Vector embedding policies
  • Vector indexing policies
  • The VectorDistance() system function

Vector indexes improve vector-search efficiency by reducing latency and RU consumption compared with an unindexed/full-scan approach.

At a conceptual level:

                  Azure Cosmos DB
+---------------------+
| |
Document ---> | Original content |
| |
Embedding --> | Vector embedding |
| |
| Vector index |
| |
+----------+----------+
^
|
VectorDistance()
|
Query embedding

6. Vector Embedding Policies

A vector embedding policy describes the vector properties that Cosmos DB should treat as embeddings.

The policy can specify characteristics such as:

  • The vector property path
  • Number of dimensions
  • Distance function
  • Data type

The policy establishes how Cosmos DB should interpret the vector data.

A simplified conceptual configuration might look like:

{
"vectorEmbeddings": [
{
"path": "/embedding",
"dataType": "float32",
"dimensions": 1536,
"distanceFunction": "cosine"
}
]
}

The exact configuration supported depends on the current Cosmos DB capabilities and account configuration, but the important exam concept is:

The vector embedding policy describes the characteristics of the vector data.

Don’t confuse this with the vector indexing policy.


7. Vector Indexing Policies

The vector indexing policy determines how Cosmos DB indexes the vectors for vector search.

Azure Cosmos DB for NoSQL currently provides three primary vector index types:

IndexGeneral purpose
flatExact/brute-force vector search
quantizedFlatQuantized vector search for smaller/scoped workloads
diskANNEfficient approximate vector search for larger workloads

Choosing the appropriate index is an important architectural decision.


8. The flat Vector Index

The flat index performs a brute-force comparison of vectors.

Its major advantage is accuracy.

A flat search can provide exact nearest-neighbor results.

However, it has a maximum vector dimensionality of 505 dimensions, which makes it unsuitable for many modern high-dimensional embedding models.

It can be appropriate for relatively small vector datasets or situations where exact recall is particularly important.

Key exam concept

Flat = exact/brute-force search.


9. The quantizedFlat Vector Index

quantizedFlat compresses vectors before storing them in the vector index.

This can provide:

  • Lower latency
  • Higher throughput
  • Lower RU consumption

compared with an ordinary flat index.

The trade-off is that quantization can result in some loss of accuracy.

quantizedFlat supports vectors up to 4,096 dimensions.

Microsoft currently describes quantizedFlat as particularly appropriate for smaller or more narrowly scoped searches, with 50,000 vectors or fewer in the search scope being a useful general guideline—not an absolute limit. Actual workloads should be benchmarked.

Key exam concept

quantizedFlat = compressed/brute-force search with improved efficiency and a possible small accuracy trade-off.


10. The diskANN Vector Index

diskANN is designed for efficient approximate vector search, particularly for larger workloads.

It can provide:

  • Low latency
  • High throughput
  • Efficient RU consumption
  • High retrieval accuracy

It supports vectors up to 4,096 dimensions.

Microsoft describes DiskANN as generally the most performant option when the search scope exceeds approximately 50,000 vectors, although actual workload testing remains important.

Key exam concept

diskANN = approximate vector search optimized for larger datasets/search scopes.


11. Vector Index Comparison

For exam preparation, remember the following:

CharacteristicflatquantizedFlatdiskANN
Search typeExact/brute forceQuantized brute forceApproximate
Maximum dimensions5054,0964,096
AccuracyExactSlight possible lossHigh, configurable trade-offs
Large datasetsPoor fitBetter for smaller/scoped dataExcellent
Latency at scaleHigherModerateLower
RU efficiency at scaleLowerBetterBetter
Typical useSmall/exact searchesSmaller/scoped searchesLarge-scale vector search

12. Important Requirement: Vector Index Configuration

A vector index must be configured for the vector property that will be searched.

For example:

"vectorIndexes": [
{
"path": "/embedding",
"type": "diskANN"
}
]

The vector embedding policy and vector index work together.

A useful way to remember the distinction is:

Embedding policy = What is my vector?

Vector index = How should I search my vector?


13. Performing Vector Similarity Search

The primary Cosmos DB function used for vector similarity search is:

VectorDistance()

A basic query might look like:

SELECT TOP 10
c.title,
VectorDistance(c.embedding, @queryVector) AS SimilarityScore
FROM c
ORDER BY VectorDistance(c.embedding, @queryVector)

This query:

  1. Takes the query vector.
  2. Compares it with c.embedding.
  3. Calculates a vector distance.
  4. Sorts the results.
  5. Returns the top 10 results.

Microsoft specifically recommends using TOP N for vector searches because returning unnecessary results increases RU consumption and latency.


14. Understanding VectorDistance()

The function conceptually compares:

Document vector
|
v
VectorDistance()
^
|
Query vector

The result represents the distance between the vectors.

The exact interpretation depends on the configured distance function.

Common distance concepts include:

  • Cosine
  • Euclidean
  • Dot product

The application should use the distance function appropriate for the embedding model and workload.


15. Why Distance Matters

Suppose the query embedding is:

Q = [0.2, 0.3, 0.5]

and the database contains:

A = [0.2, 0.3, 0.5]
B = [0.8, 0.1, 0.2]
C = [-0.4, 0.7, 0.1]

The vector closest to the query is likely the most semantically similar.

The search engine can therefore rank results:

1. Document A
2. Document B
3. Document C

The application doesn’t have to know the meaning represented by every dimension.

The embedding model and vector-distance calculation handle that mathematical representation.


16. Always Use TOP N

A particularly important exam and practical-development point is:

Use TOP N with vector searches.

For example:

SELECT TOP 5
c.id,
c.title,
VectorDistance(c.embedding, @queryVector) AS score
FROM c
ORDER BY VectorDistance(c.embedding, @queryVector)

If the application only needs the five most relevant documents, there’s little reason to retrieve thousands of results.

Returning unnecessary results can increase:

  • RU consumption
  • Latency
  • Network traffic
  • Application processing

Microsoft explicitly recommends TOP N for vector searches.


17. Filtering Vector Searches

Vector search can also be combined with traditional query filtering.

For example:

SELECT TOP 10
c.title,
c.category,
VectorDistance(c.embedding, @queryVector) AS score
FROM c
WHERE c.category = "travel"
ORDER BY VectorDistance(c.embedding, @queryVector)

This means:

Find the most semantically similar documents within the travel category.

This is extremely useful in real applications.

Examples include:

  • Search products within a specific department.
  • Search documents belonging to a specific tenant.
  • Search hotel information within a particular region.
  • Search only documents that a user is authorized to access.

Azure Cosmos DB supports combining vector search with other query filtering capabilities.


18. Vector Search and Partitioning

Azure Cosmos DB applications should always consider partitioning.

For example, a multi-tenant application might have:

{
"id": "doc123",
"tenantId": "tenantA",
"title": "Company policy",
"embedding": [...]
}

A query could restrict retrieval to a particular tenant:

SELECT TOP 10
c.title,
VectorDistance(c.embedding, @queryVector) AS score
FROM c
WHERE c.tenantId = @tenantId
ORDER BY VectorDistance(c.embedding, @queryVector)

This can narrow the search scope and can be important for both performance and data isolation.


19. Semantic Search vs. Keyword Search

It is important to understand the difference.

Keyword search

A keyword search primarily asks:

Does this document contain the requested word or phrase?

For example:

"automobile"

might fail to find a document that only says:

"car"

Semantic search

Semantic search asks:

Which documents are mathematically closest in meaning to this query?

Therefore:

"automobile"

may retrieve documents discussing:

cars
vehicles
motor vehicles
transportation

depending on how the embedding model represents the concepts.


20. Hybrid Search

Vector search doesn’t have to replace traditional search.

Many AI applications use hybrid search, combining:

  • Keyword/full-text search
  • Vector similarity
  • Metadata filtering

For example:

User query
|
+--------------------+
| |
v v
Keyword search Vector search
| |
+---------+----------+
|
v
Combined ranking
|
v
Relevant results

This can provide better retrieval than relying exclusively on either keyword or vector search.

For example, vector search is good at identifying semantic similarity, while keyword search can be valuable when an exact product ID, name, or technical term matters.


21. Vector Search and RAG

One of the most important practical applications of vector search is Retrieval-Augmented Generation (RAG).

A simplified RAG architecture looks like this:

              DOCUMENT INGESTION
|
v
Generate embeddings
|
v
Azure Cosmos DB
+----------------------+
| Documents |
| Embeddings |
| Vector index |
+----------------------+

^
|
Vector retrieval
|
|
User question --> Generate embedding
|
v
Vector similarity search
|
v
Relevant documents
|
v
LLM
|
v
Generated answer

The vector database is responsible for retrieving relevant information.

The LLM is responsible for generating the final response using that retrieved information.

This distinction is important.

Vector search retrieves information; the LLM generates the response.


22. Keeping Embeddings Synchronized

Suppose the source document changes:

Original document
|
v
Embedding A

The document is updated:

Updated document
|
v
Embedding A <-- stale!

The embedding may no longer accurately represent the document.

Therefore, applications should have a mechanism to regenerate embeddings when source content changes.

Azure Cosmos DB’s change feed can be used as part of an architecture that detects changes and triggers embedding regeneration. The current AI-200 training material specifically includes change-feed processing for keeping embeddings synchronized.

A common architecture is:

Document updated
|
v
Cosmos DB change feed
|
v
Processing component
|
v
Generate new embedding
|
v
Update Cosmos DB item

23. Vector Index Limitations You Should Know

Several limitations are particularly relevant for the AI-200 exam.

Maximum dimensions

Current limits include:

  • flat: 505 dimensions
  • quantizedFlat: 4,096 dimensions
  • diskANN: 4,096 dimensions

Minimum vectors for quantizedFlat and diskANN

quantizedFlat and diskANN require at least 1,000 vectors for indexed vector searching. If fewer than 1,000 vectors are present, a full scan can be performed instead.

Shared throughput

Vector indexing and search currently aren’t supported on accounts using shared throughput.

Vector policy changes

Vector embedding and vector indexing policy settings aren’t simply modified in place. Depending on the specific configuration, the existing policy/index must be removed and recreated, or a new container may be required.

Vector search cannot simply be disabled

Once vector indexing and search are enabled on a container, it cannot simply be disabled.


24. Common Exam Traps

Trap 1: Confusing embeddings with indexes

An embedding is the numerical representation of content.

An index is the structure used to efficiently search those vectors.


Trap 2: Thinking Cosmos DB generates the embedding

Cosmos DB stores and searches embeddings.

An embedding model, such as an embedding API, generates the embedding.


Trap 3: Assuming diskANN is exact

diskANN is an approximate nearest-neighbor approach.

It is designed to provide excellent performance while maintaining high retrieval quality.


Trap 4: Assuming quantizedFlat is exact

Quantization can introduce a small loss of accuracy.


Trap 5: Forgetting TOP N

A vector search should generally use TOP N to avoid unnecessarily expensive retrieval.


Trap 6: Using flat for a 1,536-dimensional embedding

The current flat limit is 505 dimensions.

A 1,536-dimensional embedding requires a vector index type supporting that dimensionality, such as quantizedFlat or diskANN.


Trap 7: Treating vector search as keyword search

Vector search is based on semantic similarity, not exact text matching.


25. Exam-Focused Summary

For AI-200, remember this chain:

Source data
|
v
Embedding model
|
v
Vector embedding
|
v
Cosmos DB document
|
v
Vector embedding policy
|
v
Vector index
|
v
VectorDistance()
|
v
TOP N results
|
v
Semantic retrieval

The most important concepts are:

ConceptRemember
EmbeddingNumerical representation of content
Vector storeStores and retrieves embeddings
Vector embedding policyDefines characteristics of vectors
Vector indexMakes vector searches more efficient
flatExact/brute-force; max 505 dimensions
quantizedFlatQuantized; max 4,096 dimensions
diskANNApproximate, efficient large-scale search; max 4,096 dimensions
VectorDistance()Performs vector distance calculation
TOP NLimits results and helps control RU/latency
Semantic searchFinds content by meaning
Metadata filteringNarrows the search space
Hybrid searchCombines lexical and vector retrieval
RAGUses retrieved context to augment LLM generation
Change feedCan trigger embedding refresh when data changes

Practice Exam Questions

Question 1

An AI application stores product descriptions in Azure Cosmos DB for NoSQL. The application needs to find products that are semantically similar to a user’s natural-language query.

What should the application do?

A. Store the product descriptions as strings and use CONTAINS() exclusively.

B. Generate embeddings for the product descriptions and store the vectors with the documents.

C. Convert each product description to a partition key.

D. Store each word as a separate Cosmos DB item.

Answer: B

Explanation:
Semantic retrieval requires converting content into vector embeddings. The embeddings can then be stored alongside the original documents in Cosmos DB and compared with a query embedding. Keyword functions such as CONTAINS() don’t provide semantic similarity.


Question 2

An application uses a 1,536-dimensional embedding model and needs an efficient vector index for a large production dataset.

Which vector index type is the most appropriate choice?

A. flat

B. hash

C. range

D. diskANN

Answer: D

Explanation:
diskANN supports vectors up to 4,096 dimensions and is designed for efficient approximate vector search at larger scales. flat is limited to 505 dimensions and therefore cannot index a 1,536-dimensional vector.


Question 3

An application needs the five most semantically similar documents to a query vector.

Which query pattern should be used?

A.

SELECT *
FROM c
ORDER BY VectorDistance(c.embedding, @queryVector)

B.

SELECT TOP 5 *
FROM c
ORDER BY c.embedding

C.

SELECT TOP 5 *
FROM c
ORDER BY VectorDistance(c.embedding, @queryVector)

D.

SELECT *
FROM c
WHERE c.embedding = @queryVector

Answer: C

Explanation:
VectorDistance() calculates the distance between the stored embedding and query vector. TOP 5 limits the results to the five most relevant documents and helps avoid unnecessary RU consumption and latency.


Question 4

Which statement best describes the purpose of a vector embedding?

A. It is a Cosmos DB authentication token.

B. It is the partition key automatically generated by Cosmos DB.

C. It is a numerical representation of the semantic characteristics of content.

D. It is an index containing document metadata.

Answer: C

Explanation:
An embedding is a numerical representation generated by an embedding model. Semantically related content tends to produce vectors that are close together in vector space.


Question 5

A company has a relatively small vector search workload and wants to use a vector index that compresses vectors to improve efficiency while accepting a possible small loss in accuracy.

Which index should it consider?

A. flat

B. quantizedFlat

C. diskANN

D. NoSQL range indexing

Answer: B

Explanation:
quantizedFlat compresses vectors before indexing. This can improve latency, throughput, and RU efficiency compared with flat, at the potential cost of some accuracy. It is particularly suited to smaller or more narrowly scoped searches.


Question 6

An application has documents containing both an embedding and a category property. It needs to find the most semantically similar documents, but only within the "finance" category.

Which approach is appropriate?

A. Perform a vector search without filtering and discard non-finance results afterward.

B. Store each category in a separate Cosmos DB account.

C. Use VectorDistance() together with a WHERE filter for the category.

D. Replace the embeddings with category names.

Answer: C

Explanation:
Vector search can be combined with traditional Cosmos DB query filters. The application can use a WHERE clause to restrict the search to documents matching the required metadata.


Question 7

A developer changes the text of a document but continues using the embedding that was generated from the old version.

What is the primary problem?

A. The partition key automatically changes.

B. The vector index is deleted.

C. The document becomes unreadable.

D. The embedding may no longer accurately represent the document.

Answer: D

Explanation:
An embedding represents the content used to generate it. If the source content changes substantially, the old embedding can become stale. Applications can use mechanisms such as the Cosmos DB change feed to detect changes and trigger embedding regeneration.


Question 8

Which statement correctly describes the flat vector index in Azure Cosmos DB for NoSQL?

A. It performs exact/brute-force vector search and supports vectors up to 505 dimensions.

B. It performs approximate DiskANN search and supports 4,096 dimensions.

C. It compresses vectors and always produces approximate results.

D. It is used only for keyword searches.

Answer: A

Explanation:
The flat index performs brute-force vector search and can provide exact nearest-neighbor results. Its current maximum vector dimensionality is 505.


Question 9

An AI application uses vector search as part of a RAG architecture.

What is the primary purpose of the vector search portion of the architecture?

A. Generate the final natural-language response.

B. Retrieve content that is semantically relevant to the user’s query.

C. Train the large language model.

D. Replace the embedding model.

Answer: B

Explanation:
Vector search retrieves relevant information based on semantic similarity. The retrieved content can then be supplied to an LLM as context for generating the final answer. Vector retrieval and LLM generation are separate responsibilities.


Question 10

A developer creates a vector search query that returns every matching document instead of limiting the result set. The application only needs the top 10 results.

What should the developer change?

A. Remove the vector index.

B. Increase the embedding dimensionality.

C. Add a TOP 10 clause to the query.

D. Replace VectorDistance() with CONTAINS().

Answer: C

Explanation:
Vector searches should generally use TOP N to limit the number of returned results. Returning more results than the application needs can increase RU consumption and latency.


Final Exam Takeaways

If you remember only a handful of things from this topic, remember these:

  1. Embeddings represent the semantic characteristics of content numerically.
  2. An embedding model generates the embedding; Cosmos DB stores and searches it.
  3. Embeddings can be stored alongside the original Cosmos DB document.
  4. VectorDistance() is the key function for vector similarity searches.
  5. Use TOP N when performing vector retrieval.
  6. flat provides exact/brute-force search but is limited to 505 dimensions.
  7. quantizedFlat provides a more efficient quantized approach for smaller/scoped searches.
  8. diskANN is designed for efficient approximate search at larger scales and supports up to 4,096 dimensions.
  9. Vector search can be combined with metadata filters and hybrid search.
  10. Vector retrieval is a fundamental building block for RAG applications.
  11. When source content changes, embeddings may need to be regenerated.
  12. For AI-200 scenario questions, pay close attention to the dataset size, vector dimensionality, accuracy requirements, RU consumption, and latency requirements when selecting a vector index.

Go to the AI-200 Exam Prep Hub main page

Monitor and troubleshoot solutions on AKS and Container Apps by inspecting logs, events, and end-to-end connectivity (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container-orchestrated solutions
      --> Monitor and troubleshoot solutions on AKS and Container Apps by inspecting logs, events, and end-to-end connectivity


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Modern AI applications frequently run as distributed containerized solutions. A typical application might include several containers, APIs, background workers, databases, messaging services, and external Azure services. When something goes wrong, determining where the problem exists is often more difficult than identifying that a problem exists.

For the AI-200 exam, developers should understand how to troubleshoot applications running on:

  • Azure Kubernetes Service (AKS)
  • Azure Container Apps
  • The networking and services that connect application components
  • Azure monitoring and logging capabilities

A particularly important skill is knowing how to work from the application outward:

Application/container → Pod or replica → Service/ingress → Network → Destination

This approach helps isolate whether a problem is caused by the application itself, the container runtime, Kubernetes configuration, service discovery, ingress, networking, or an external dependency.


1. The Troubleshooting Mindset

When an application is failing, avoid immediately changing configuration. First determine which layer is failing.

A useful troubleshooting sequence is:

  1. Is the application running?
  2. Is the container healthy?
  3. Are there useful application logs?
  4. Are there Kubernetes or platform events indicating a problem?
  5. Can the application communicate with its immediate dependency?
  6. Can the service route traffic to the application?
  7. Can traffic enter or leave the application environment?
  8. Is the external dependency itself healthy?

For AKS, Microsoft recommends an inside-out approach for connectivity problems: begin with the pod and application, then work outward through the service and networking layers toward the client or destination.

This approach is particularly useful on the exam because a scenario may provide several symptoms but only one layer is actually responsible for the failure.


2. Logs vs. Events vs. Metrics

One of the most important distinctions to understand is the difference between logs, events, and metrics.

SignalWhat it tells youTypical use
LogsWhat the application or platform reportedApplication errors, exceptions, startup failures
EventsWhat happened to an infrastructure/resource objectScheduling failures, image pulls, restarts
MetricsNumerical measurements over timeCPU, memory, request rate, latency
TracesHow a request traveled through distributed componentsEnd-to-end request troubleshooting

Logs

Logs are particularly useful when the application itself knows why it failed.

Examples include:

  • Database connection failures
  • Authentication errors
  • Exceptions
  • Invalid configuration
  • Failed API calls
  • Application startup errors

Events

Events are especially useful when Kubernetes or the hosting platform is having difficulty creating, scheduling, starting, or managing a workload.

Examples include:

  • Failed scheduling
  • Failed image pulls
  • Container creation failures
  • Probe failures
  • Pod restarts
  • Resource constraints

Metrics

Metrics help identify patterns rather than individual failures.

Examples include:

  • CPU utilization
  • Memory utilization
  • Request rate
  • Replica count
  • Network traffic
  • Latency
  • Restart counts

A common exam scenario is:

An application is slow and occasionally unavailable.

Logs may identify the immediate application error, while metrics may reveal that CPU or memory is saturated and events may reveal that pods are being restarted.

You often need all three signals to understand the complete problem.


3. Monitoring and Troubleshooting AKS

AKS provides Kubernetes-native troubleshooting capabilities together with Azure monitoring services.

Important tools include:

  • kubectl get
  • kubectl describe
  • kubectl logs
  • kubectl exec
  • kubectl get events
  • Azure Monitor
  • Container insights
  • Azure portal
  • Application logs
  • Kubernetes events
  • Metrics

4. Start by Checking Pod Status

The first question is simple:

Is the workload actually running?

Use:

kubectl get pods

For a specific namespace:

kubectl get pods -n <namespace>

To see pods across all namespaces:

kubectl get pods -A

You might see states such as:

  • Running
  • Pending
  • Succeeded
  • Failed
  • CrashLoopBackOff
  • ImagePullBackOff
  • ErrImagePull
  • ContainerCreating
  • Terminating

These statuses provide an initial indication of where to investigate.

Example

Suppose you see:

NAME READY STATUS RESTARTS
ai-worker-7f4b8c9d8-x2k4m 0/1 CrashLoopBackOff 8

The pod is repeatedly starting and failing.

The next step should generally be to investigate the pod rather than immediately examining the network.


5. Use kubectl describe to Examine Resource Details and Events

Use:

kubectl describe pod <pod-name>

Or:

kubectl describe pod <pod-name> -n <namespace>

kubectl describe provides detailed information about the Kubernetes object, including its configuration, status, conditions, and associated events.

This is particularly useful for identifying problems such as:

  • Failed scheduling
  • Image pull failures
  • Insufficient resources
  • Failed health probes
  • Volume mount problems
  • Container startup problems

For example, an event such as:

Failed to pull image

points toward an image or registry problem rather than an application networking problem.

Likewise:

FailedScheduling

suggests that Kubernetes cannot place the pod on an appropriate node.


6. Kubernetes Events

Kubernetes events record significant activities involving Kubernetes resources.

Examples include:

  • Pod scheduling
  • Container creation
  • Container startup
  • Image pulling
  • Failed scheduling
  • Probe failures
  • Resource-related problems

You can list events with:

kubectl get events

For a namespace:

kubectl get events -n <namespace>

Events can also be sorted or filtered when investigating a particular problem.

Kubernetes events are extremely useful for troubleshooting, but they are not intended to be a permanent application log store. By default, Kubernetes events have limited retention; current Azure documentation notes that events are available for approximately one hour unless longer-term collection is configured through monitoring capabilities such as Container insights.

Exam Tip

If a question asks:

“Which tool should you use to determine why a pod failed to start?”

Think:

kubectl describe pod and Kubernetes events

If the question asks:

“What did the application itself report?”

Think:

container logs


7. Inspect Container Logs in AKS

Use:

kubectl logs <pod-name>

For a specific namespace:

kubectl logs <pod-name> -n <namespace>

For a particular container in a multi-container pod:

kubectl logs <pod-name> -c <container-name>

This is especially useful when:

  • The application starts and then crashes
  • The application throws an exception
  • A dependency cannot be reached
  • Configuration is invalid
  • Authentication fails
  • The application is returning errors

8. Inspect Logs from a Previous Container Instance

This is an important troubleshooting technique.

If a container has crashed and restarted, its current log may not contain the information from the previous instance.

Use:

kubectl logs <pod-name> --previous

For a particular container:

kubectl logs <pod-name> -c <container-name> --previous

This is particularly valuable when diagnosing:

  • CrashLoopBackOff
  • Startup failures
  • Unexpected application termination
  • Configuration errors during initialization

Exam Scenario

A pod repeatedly restarts. The current container appears healthy, but you need to determine why the previous instance terminated.

The appropriate command is:

kubectl logs <pod-name> --previous

9. Kubernetes Health Probes

Health probes are another major source of troubleshooting information.

Kubernetes supports:

Liveness probe

Determines whether a container is still functioning.

If the liveness probe repeatedly fails, Kubernetes can restart the container.

Readiness probe

Determines whether the application is ready to receive traffic.

A container can be running but not ready.

Startup probe

Provides additional time for applications that require significant startup time before liveness/readiness checks should begin.


Why Probes Matter

Consider an AI inference service that requires 60 seconds to load a model.

If its liveness probe begins failing after only 10 seconds, Kubernetes may repeatedly restart the container before the model finishes loading.

The result can be:

CrashLoopBackOff

even though the application itself is not fundamentally broken.

Therefore, when investigating repeated restarts, inspect:

kubectl describe pod <pod-name>

and look for probe-related events.


10. Inspect AKS Services

A pod’s IP address is generally not the endpoint that clients should depend on.

Kubernetes Services provide stable networking for workloads.

List services:

kubectl get svc

Describe a service:

kubectl describe svc <service-name>

You should investigate:

  • Service type
  • Port
  • Target port
  • Selector
  • Cluster IP
  • Endpoints
  • Associated pods

A common failure is a Service selector that does not match the labels on the intended pods.

For example, a Service might select:

selector:
app: ai-api

while the pods actually have:

labels:
app: ai-service

The pods may be healthy, but the Service has no appropriate endpoints.


11. Check Service Endpoints

One of the most important connectivity checks is determining whether a Service actually has endpoints.

For example:

kubectl get endpoints <service-name>

Depending on the Kubernetes version and configuration, EndpointSlices can also be examined:

kubectl get endpointslices

If the Service has no usable endpoints, traffic cannot be routed to the expected application pods.

This creates an important troubleshooting distinction:

Pod is healthy ≠ Service is correctly routing traffic


12. Test Connectivity from Inside the Cluster

When troubleshooting network connectivity, testing from inside the cluster can eliminate several variables.

For example, you can run a temporary diagnostic pod and test connectivity to another service.

Useful tools can include:

nslookup <service-name>
curl http://<service-name>:<port>

or:

nc -z -v <host> <port>

The exact tools available depend on the container image.

This allows you to determine whether:

  • DNS resolution works
  • The destination port is reachable
  • The service responds
  • The application is actually listening

13. End-to-End AKS Connectivity Troubleshooting

Consider this architecture:

Internet
|
v
Ingress / Load Balancer
|
v
Kubernetes Service
|
v
Pod
|
v
Application
|
v
External Azure Service

A useful troubleshooting process is to work through the architecture one layer at a time.

Step 1: Is the pod running?

kubectl get pods

Step 2: Is the application healthy?

kubectl logs <pod-name>

Step 3: Are there Kubernetes events?

kubectl describe pod <pod-name>

Step 4: Does the Service exist?

kubectl get svc

Step 5: Does the Service have endpoints?

kubectl get endpoints <service-name>

Step 6: Can another pod reach the Service?

Use a test container and:

curl http://<service-name>:<port>

Step 7: Does DNS work?

For example:

nslookup <service-name>

Step 8: Does external ingress work?

Test the externally exposed endpoint.

Step 9: Can the application reach external dependencies?

Test the required destination from inside the workload.

This approach prevents you from assuming that every connectivity problem is an ingress problem.


14. Container Insights for AKS

Azure Monitor Container insights provides monitoring capabilities for AKS.

It can provide visibility into:

  • Container logs
  • Kubernetes events
  • Pod metrics
  • Cluster information
  • Resource utilization

The Live Data capability can provide direct access to AKS container logs, events, and pod metrics for real-time troubleshooting.

This can be particularly useful when you want Azure-based monitoring rather than relying exclusively on command-line Kubernetes tools.

Important distinction

kubectl logs is a Kubernetes-native method for retrieving container logs.

Container insights provides an Azure monitoring experience that can aggregate and visualize Kubernetes telemetry.


15. Azure Container Apps Monitoring

Azure Container Apps abstracts much of the underlying Kubernetes infrastructure.

Unlike AKS, you generally do not troubleshoot Container Apps by directly managing Kubernetes nodes and pods.

Instead, use Container Apps’ platform-level monitoring capabilities.

Important sources include:

  • Container console logs
  • System logs
  • HTTP logs
  • Log streams
  • Azure Monitor
  • Application Insights
  • Metrics
  • Diagnose and solve problems

16. Container App Console Logs

Container console logs originate from the application’s:

  • stdout
  • stderr

These are useful for diagnosing application-level problems.

For example:

Database connection failed

or:

Authentication failed

or:

Unhandled exception

These messages can help identify problems inside the application.

Azure Container Apps allows console logs to be viewed through the Azure portal and CLI.


17. Container Apps System Logs

System logs are generated by the Container Apps service rather than directly by the application.

They can help identify platform-level problems such as:

  • Revision provisioning failures
  • Container startup issues
  • Configuration problems
  • Volume mounting failures
  • Dapr component issues
  • Application configuration changes
  • Other service-level events

This creates an important exam distinction:

ProblemMost useful source
Application exceptionConsole logs
Revision provisioning failureSystem logs
Container lifecycle issueSystem/platform logs
HTTP request behaviorHTTP logs
Resource utilizationMetrics

18. Viewing Container Apps Log Streams

In the Azure portal, navigate to the Container App and select:

Monitoring → Log stream

You can select between:

  • Console
  • System

The console stream displays application/container output, while the system stream provides platform-level information.

You can also use the Azure CLI.

For example:

az containerapp logs show \
--name <CONTAINER_APP_NAME> \
--resource-group <RESOURCE_GROUP> \
--type console

For system logs:

az containerapp logs show \
--name <CONTAINER_APP_NAME> \
--resource-group <RESOURCE_GROUP> \
--type system

You can use --tail to limit the number of messages and --follow to continuously stream logs.


19. Container Apps Revisions and Replicas

Container Apps uses revisions and replicas.

This matters when troubleshooting because the application may have:

  • Multiple revisions
  • Multiple replicas
  • Multiple containers

A log problem might exist only in one revision or replica.

Therefore, when investigating Container Apps logs, determine:

  1. Which revision is receiving traffic?
  2. Which replica is experiencing the problem?
  3. Which container is producing the error?
  4. Is the problem isolated or occurring across all replicas?

This is particularly important during deployments.

For example:

Revision A → healthy
Revision B → failing

If traffic has been shifted to Revision B, users may experience failures even though Revision A remains healthy.


20. Container Apps and Scaling to Zero

Container Apps can scale an application down to zero replicas depending on its scaling configuration.

This creates a potential troubleshooting trap.

If an application is scaled to zero, there may be no active replica from which to stream console logs.

If the log stream indicates that the revision is scaled to zero, you may need to temporarily configure a minimum replica count greater than zero to investigate the running application.

Exam Tip

If a Container App has no active replicas:

Don’t assume the application has crashed.

It may simply have scaled to zero.


21. Container Apps HTTP Logs

Container Apps can also provide HTTP-related telemetry through its ingress layer when diagnostic settings are configured.

These logs can help investigate:

  • HTTP status codes
  • Request behavior
  • Client requests
  • Ingress problems
  • Application availability

This is useful when the container itself appears healthy but clients are receiving errors.

For example:

Client → Container Apps ingress → Container

If the container logs show no corresponding request, investigate the ingress/routing layer.


22. Diagnose and Solve Problems in Container Apps

Azure Container Apps provides a Diagnose and solve problems experience for investigating application health, configuration, and performance.

This can be useful when problems are not immediately obvious from application logs.

For example, Container Apps diagnostics can help investigate container exit events and provide information about possible causes and resolutions.


23. AKS vs. Container Apps Troubleshooting

Understanding the difference between AKS and Container Apps is important for AI-200.

AreaAKSAzure Container Apps
Kubernetes API accessYesAbstracted from developer
kubectl troubleshootingYesGenerally not the primary approach
Pod troubleshootingYesPlatform abstracts replicas
Kubernetes eventsDirectly availablePlatform-level diagnostics/logs
Container logskubectl logsLog stream / CLI
System logsKubernetes/Azure monitoringContainer Apps system logs
Service configurationKubernetes ServicesContainer Apps ingress
ScalingKubernetes autoscaling mechanismsContainer Apps scaling rules
Node troubleshootingPossibleManaged/abstracted
Azure MonitorYesYes
Container InsightsAvailableNot the primary troubleshooting interface

Key Exam Principle

If a question emphasizes:

Pods, nodes, Services, Deployments, Kubernetes events, kubectl

think:

AKS

If it emphasizes:

Revisions, replicas, Container Apps log streams, system logs, console logs, ingress

think:

Azure Container Apps


24. Troubleshooting Common AKS Problems

Problem: Pod is Pending

Check:

kubectl describe pod <pod-name>

Look for events such as:

FailedScheduling

Potential causes include:

  • Insufficient CPU
  • Insufficient memory
  • Node constraints
  • Affinity rules
  • Taints and tolerations
  • Resource quotas

Problem: ImagePullBackOff

Check:

kubectl describe pod <pod-name>

Potential causes include:

  • Incorrect image name
  • Incorrect image tag
  • Private registry authentication
  • Network connectivity to the registry
  • Image does not exist

Problem: CrashLoopBackOff

Check:

kubectl logs <pod-name>

Then:

kubectl logs <pod-name> --previous

And:

kubectl describe pod <pod-name>

Potential causes include:

  • Application crash
  • Invalid configuration
  • Missing secret
  • Failed dependency connection
  • Failed liveness probe
  • Incorrect startup behavior

Problem: Pod is Running but Requests Fail

Investigate:

  1. Application logs
  2. Pod readiness
  3. Service configuration
  4. Service endpoints
  5. DNS
  6. Network policies
  7. Ingress/load balancer
  8. External networking

A Running status does not guarantee that an application is reachable.


25. Troubleshooting Common Container Apps Problems

Problem: Container exits

Check:

  • Console logs
  • System logs
  • Container exit events
  • Revision status
  • Application startup configuration

A zero exit code can indicate normal termination, while a nonzero exit code generally indicates failure. Container Apps provides diagnostic information about container exit events.


Problem: Application is unavailable

Check:

  1. Active revision
  2. Replica count
  3. Ingress configuration
  4. Console logs
  5. System logs
  6. HTTP logs
  7. Health probes
  8. Application dependencies

Problem: New deployment fails

Check:

  • Revision provisioning
  • Container image
  • Environment variables
  • Secrets
  • Managed identity
  • Registry access
  • Container startup
  • Application logs

A new revision can fail while a previous revision continues to operate.


26. Troubleshooting End-to-End Connectivity

End-to-end connectivity problems require a broader perspective.

Consider an AI application with this architecture:

User
|
v
Azure Front Door / Application Gateway
|
v
Container App or AKS Ingress
|
v
Application
|
+------> Azure OpenAI
|
+------> Azure Cosmos DB
|
+------> Azure Service Bus
|
+------> Azure Storage

A failure could occur anywhere along this path.

The correct troubleshooting approach is to identify the first point at which communication fails.


27. Test from the Same Network Context

A common troubleshooting mistake is testing connectivity from your laptop when the actual application runs inside Azure.

For example:

Laptop → Azure service

may work while:

Container → Azure service

fails.

The application should therefore be tested from the same network context in which it runs.

For AKS, this may mean executing commands from a diagnostic pod.

For Container Apps, troubleshooting may involve application logs, platform diagnostics, ingress configuration, and network configuration.


28. DNS Troubleshooting

DNS problems can make a healthy application appear unavailable.

Suppose an application attempts:

https://my-database.example.com

but cannot resolve the hostname.

The application may produce errors such as:

Name or service not known

or:

DNS resolution failed

In AKS, test DNS from inside the cluster:

nslookup <hostname>

or:

nslookup <service-name>

If DNS resolution fails, investigate DNS configuration before investigating the application itself.


29. Port and Protocol Troubleshooting

A common problem is confusing:

  • Container port
  • Service port
  • Target port
  • External port

For example:

Client
|
| TCP 443
v
Ingress
|
| TCP 8080
v
Service
|
| TCP 8080
v
Pod

The application must actually be listening on the expected port.

A connectivity test such as:

nc -z -v <host> <port>

can help determine whether a TCP port is reachable.


30. Application Connectivity vs. Infrastructure Connectivity

Another important distinction is:

Can the network connection be established?

versus:

Does the application successfully process the request?

For example:

TCP connection succeeds
|
v
HTTP 500

The network is functioning, but the application has an error.

Conversely:

Connection timeout

may indicate a networking, routing, firewall, DNS, or service availability problem.

The HTTP response code and application logs should therefore be considered together.


31. A Practical AKS Troubleshooting Playbook

When an AKS application is unavailable, use this sequence.

Step 1 — Check pods

kubectl get pods -A

Step 2 — Inspect unhealthy pods

kubectl describe pod <pod-name>

Step 3 — Read logs

kubectl logs <pod-name>

Step 4 — Check previous container logs

kubectl logs <pod-name> --previous

Step 5 — Check events

kubectl get events

Step 6 — Check Services

kubectl get svc

Step 7 — Check endpoints

kubectl get endpoints <service-name>

Step 8 — Test DNS

nslookup <service-name>

Step 9 — Test connectivity

curl http://<service-name>:<port>

Step 10 — Investigate ingress and external networking

Only after the internal application path is confirmed should you move farther outward.


32. A Practical Container Apps Troubleshooting Playbook

For Azure Container Apps:

Step 1 — Check revision status

Determine whether the expected revision is active and healthy.

Step 2 — Check replica state

Determine whether the application has active replicas or has scaled to zero.

Step 3 — Inspect console logs

Look for application-level errors.

Step 4 — Inspect system logs

Look for platform and revision-level problems.

Step 5 — Inspect HTTP/ingress telemetry

Determine whether requests are reaching the application.

Step 6 — Check configuration

Review:

  • Environment variables
  • Secrets
  • Managed identity
  • Registry configuration
  • Ingress
  • Health probes

Step 7 — Check external dependencies

Determine whether the application can communicate with required Azure services.

Step 8 — Use Azure diagnostics

Use the Container Apps diagnostic capabilities when the source of the problem remains unclear.


33. Common Troubleshooting Mistakes

Mistake 1: Assuming Running Means Healthy

A pod can be Running while the application inside it is broken.

Use readiness status, logs, and probes.


Mistake 2: Looking Only at Application Logs

Infrastructure events may reveal the actual problem.

For example:

ImagePullBackOff

is unlikely to be explained by an application log because the application may never have started.


Mistake 3: Looking Only at Events

Events can tell you that something happened, but application logs may explain why the application itself failed.

Use both.


Mistake 4: Troubleshooting Ingress First

If the pod isn’t running, spending time troubleshooting ingress is premature.

Work from the application outward.


Mistake 5: Ignoring Previous Container Logs

A restarted container may have lost the most useful evidence.

Use:

kubectl logs --previous

Mistake 6: Assuming a Container App with No Logs Is Broken

The application might be scaled to zero.

Check its replica/scaling state.


Mistake 7: Testing from the Wrong Location

A connection that succeeds from your development machine does not prove that it will succeed from the Azure-hosted application.

Test from the application’s network context whenever possible.


34. Exam-Focused Command Reference

TaskCommand
List podskubectl get pods
List all podskubectl get pods -A
Describe podkubectl describe pod <pod>
View container logskubectl logs <pod>
View previous container logskubectl logs <pod> --previous
View a specific containerkubectl logs <pod> -c <container>
List eventskubectl get events
List serviceskubectl get svc
Describe servicekubectl describe svc <service>
View endpointskubectl get endpoints <service>
Test HTTP connectivitycurl <url>
Test DNSnslookup <hostname>
Test TCP connectivitync -z -v <host> <port>
Container Apps console logsaz containerapp logs show --type console
Container Apps system logsaz containerapp logs show --type system
Follow Container Apps logsaz containerapp logs show --follow

35. Key Concepts to Remember for AI-200

The following distinctions are particularly important for exam preparation.

AKS

kubectl get

Use it to see the current state of Kubernetes resources.

kubectl describe

Use it to investigate resource configuration, status, conditions, and events.

kubectl logs

Use it to inspect application/container output.

kubectl logs --previous

Use it to inspect logs from a previous container instance.

kubectl get events

Use it to investigate Kubernetes lifecycle and scheduling events.

Services and endpoints

Use them to determine whether traffic can be routed from a Kubernetes Service to the intended pods.

Container insights

Use Azure Monitor capabilities for broader monitoring, logs, events, and metrics.


Azure Container Apps

Console logs

Application/container output.

System logs

Container Apps platform/service events.

HTTP logs

Ingress-level HTTP activity when configured.

Log stream

Near-real-time access to console and system logs.

Revisions

Different deployed versions of an application.

Replicas

Running instances of a revision.

Diagnose and solve problems

Azure’s diagnostic capabilities for investigating application health and platform problems.


36. Final Exam Strategy

When presented with a troubleshooting scenario, identify the symptom first.

If the question mentions:

CrashLoopBackOff

Think:

  • kubectl logs
  • kubectl logs --previous
  • kubectl describe pod
  • Health probes

ImagePullBackOff

Think:

  • Image name/tag
  • Container registry
  • Authentication
  • kubectl describe pod

FailedScheduling

Think:

  • Node resources
  • Scheduling constraints
  • Taints/tolerations
  • kubectl describe pod

Pod is Running but service is unreachable

Think:

  • Service
  • Selector
  • Endpoints
  • DNS
  • Ports
  • Network policies
  • Ingress

Container Apps application error

Think:

  • Console logs

Container Apps platform/revision problem

Think:

  • System logs
  • Revision status

Container App has no active replica

Think:

  • Scaling to zero

Requests reach the application but return HTTP errors

Think:

  • Application logs
  • HTTP logs
  • Dependency failures

Application cannot reach an Azure service

Think:

  • DNS
  • Network routing
  • Firewall/network restrictions
  • Identity/authentication
  • Service availability
  • Test from the application’s network context

The most important principle is:

Don’t troubleshoot the entire system at once. Start at the failing workload and move outward until you find the first broken connection or component.


Practice Exam Questions

Question 1

An application running on AKS repeatedly enters the CrashLoopBackOff state. The development team wants to determine what happened immediately before the most recent container restart.

Which command should you use?

A. kubectl get svc <pod-name>

B. kubectl logs <pod-name> --previous

C. kubectl get events --all-namespaces

D. kubectl top nodes

Answer: B

Explanation:
kubectl logs --previous retrieves logs from the previous instance of a container. This is particularly useful when a container has crashed and restarted. kubectl get events can provide additional context, but it does not provide the application’s actual log output from the previous container instance.


Question 2

An AKS pod remains in the Pending state. You need to determine why Kubernetes has not scheduled the pod onto a node.

Which action should you take first?

A. Run kubectl logs on the pod.

B. Restart the deployment.

C. Run kubectl describe pod and inspect the Events section.

D. Check the application’s HTTP logs.

Answer: C

Explanation:
kubectl describe pod provides detailed information about the pod and its associated events. Scheduling failures such as insufficient resources, taints, affinity constraints, or other scheduling problems are commonly reported there. A pod that has not started generally will not have useful application logs.


Question 3

An AKS application is running successfully in its pod. However, requests sent through a Kubernetes Service do not reach the application.

Which investigation is most appropriate next?

A. Check whether the Service has endpoints corresponding to the application pods.

B. Restart the AKS cluster.

C. Examine only the application’s CPU utilization.

D. Delete and recreate the container image.

Answer: A

Explanation:
A healthy pod does not guarantee that a Service is routing traffic to it. Checking the Service and its endpoints helps determine whether the Service selector matches the intended pods and whether usable endpoints have been registered.


Question 4

An Azure Container Apps application is returning errors. The developer wants to see messages written by the application’s container to stdout and stderr.

Which log source should be inspected?

A. Container Apps system logs

B. Azure Activity Log

C. Kubernetes events

D. Container Apps console logs

Answer: D

Explanation:
Container Apps console logs contain output from the application’s containers, including stdout and stderr. System logs instead contain information generated by the Container Apps service.


Question 5

An Azure Container Apps application was working yesterday but now appears to have no running instances. No application errors are visible in the console log stream.

What should you investigate first?

A. Whether the container image has been deleted.

B. Whether the application has scaled to zero replicas.

C. Whether Kubernetes nodes are running.

D. Whether the AKS API server is reachable.

Answer: B

Explanation:
Container Apps can scale applications to zero replicas depending on the configured scaling rules. When no replicas are running, there may be no active container instance producing console logs. AKS node and API-server troubleshooting is not appropriate because Container Apps abstracts the underlying Kubernetes infrastructure.


Question 6

An AKS application is accessible from one pod but cannot resolve the DNS name of another Kubernetes Service.

Which troubleshooting technique is most appropriate?

A. Increase the pod’s CPU limit.

B. Restart every node in the cluster.

C. Run a DNS lookup such as nslookup from the application’s network context.

D. Rebuild the container image.

Answer: C

Explanation:
If the problem appears to be DNS resolution, testing DNS from inside the cluster helps determine whether the workload can resolve the target name. Testing from the same network context as the application is important because DNS behavior can differ between environments.


Question 7

A new revision of an Azure Container Apps application fails during deployment, while the previous revision continues to operate correctly.

Which information is most useful for determining whether the new revision encountered a platform-level provisioning problem?

A. The system logs for the Container App

B. The developer’s local application logs

C. The user’s browser cache

D. The CPU utilization of an unrelated Azure VM

Answer: A

Explanation:
Container Apps system logs contain platform-level information, including revision provisioning and service-level events. They are therefore appropriate when investigating deployment or revision provisioning failures.


Question 8

An AKS application is running, but clients receive connection timeouts. The development team wants to troubleshoot the problem using an inside-out approach.

Which sequence is most appropriate?

A. Check the external client, then immediately restart the cluster.

B. Check the Azure subscription, then rebuild the application.

C. Check the ingress first and ignore the pods.

D. Check the pod/application, then Service and endpoints, then networking and external access.

Answer: D

Explanation:
An inside-out approach begins with the workload itself and progressively moves outward. First verify that the pod and application are healthy, then verify Service routing and endpoints, and finally investigate ingress and external networking. This approach helps identify the first layer where connectivity fails.


Question 9

An AKS application container is repeatedly restarted. The application logs show no obvious error, but kubectl describe pod reports repeated liveness probe failures.

What is the most likely area to investigate?

A. The Azure subscription’s billing configuration.

B. The container’s liveness probe configuration and application startup/health behavior.

C. The user’s browser DNS cache.

D. The container registry’s image retention policy.

Answer: B

Explanation:
Repeated liveness probe failures can cause Kubernetes to restart a container. The probe’s path, port, timing, timeout, and failure thresholds should be evaluated against the application’s actual startup and health behavior.


Question 10

An AI application running in AKS can connect to an external Azure service from a developer workstation but receives connection timeouts when running inside the cluster.

Which approach provides the most useful next diagnostic step?

A. Assume the external service is unavailable.

B. Increase the application’s memory allocation.

C. Test DNS and network connectivity to the destination from inside the AKS network context.

D. Delete the application deployment and recreate it.

Answer: C

Explanation:
Successful connectivity from a developer workstation does not prove that connectivity from AKS is working. Testing DNS resolution and network connectivity from inside the cluster helps isolate problems involving routing, firewall rules, network policies, private endpoints, DNS, or other network-specific configuration.


Summary

For AI-200, monitoring and troubleshooting containerized applications is fundamentally about understanding where the failure occurs.

For AKS, become comfortable with:

  • kubectl get
  • kubectl describe
  • kubectl logs
  • kubectl logs --previous
  • kubectl get events
  • Services
  • Endpoints
  • DNS testing
  • Connectivity testing
  • Health probes
  • Azure Monitor and Container insights

For Azure Container Apps, understand:

  • Console logs
  • System logs
  • HTTP logs
  • Log streams
  • Revisions
  • Replicas
  • Scaling to zero
  • Ingress
  • Container exit events
  • Azure diagnostics

Most importantly, develop an inside-out troubleshooting methodology:

Container → application → pod/replica → Service/ingress → network → external dependency

When you can identify the first layer where communication or execution breaks, you can usually identify the correct troubleshooting tool and the most appropriate remediation.


Go to the AI-200 Exam Prep Hub main page

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

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container-orchestrated solutions
      --> Implement event-driven scaling by using Kubernetes Event‑driven Autoscaling (KEDA) in Container Apps


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Modern AI applications frequently perform work asynchronously. Instead of processing every request synchronously, an application might place work onto a queue or event stream and have one or more containerized workers process those events.

This architecture creates an important scaling question:

How can the application automatically add or remove container instances based on the amount of work waiting to be processed?

Kubernetes Event-driven Autoscaling (KEDA) provides the answer.

Azure Container Apps uses KEDA to support event-driven autoscaling. A container app can use KEDA-based scaling rules to respond to events and metrics from supported sources such as Azure Service Bus, Azure Event Hubs, Apache Kafka, and Redis. Container Apps manages the KEDA integration for you, so you don’t install or operate KEDA yourself.

For the AI-200 exam, the important skill is understanding when to use KEDA, how KEDA determines replica counts, how scaling rules are configured, and how authentication and scale limits affect the resulting application behavior.


1. What Is KEDA?

Kubernetes Event-driven Autoscaling (KEDA) is an autoscaling component designed to scale containerized workloads based on events or external metrics.

Traditional autoscaling commonly uses resource metrics such as:

  • CPU utilization
  • Memory utilization

Those metrics can be useful, but they don’t always represent the actual workload.

Consider an AI document-processing application:

                ┌──────────────────┐
Documents ────► │  Service Bus     │
                │      Queue       │
                └────────┬─────────┘
                         │
                         │ Pending messages
                         ▼
                ┌──────────────────┐
                │ KEDA scaler      │
                └────────┬─────────┘
                         │
                  Scale decision
                         │
              ┌──────────┴──────────┐
              ▼                     ▼
        Container App         Container App
          Replica 1             Replica 2

If there are only a few messages, the application may need only one replica.

If thousands of messages are waiting, additional replicas can be created to process the workload concurrently.

This is event-driven autoscaling.


2. KEDA in Azure Container Apps

Azure Container Apps incorporates KEDA into its scaling architecture.

This is an important exam distinction:

You don’t deploy and manage a separate KEDA installation for an Azure Container App.

Instead, you configure a scale rule on the container app. Azure Container Apps uses KEDA behind the scenes to evaluate the rule and determine how many replicas are needed.

Conceptually:

External event source
KEDA scaler
Scale rule evaluation
Desired replica count
Azure Container Apps
├── Replica 1
├── Replica 2
├── Replica 3
└── ...

This makes KEDA particularly useful for background workers and asynchronous AI workloads.


3. Why Event-Driven Scaling Is Important for AI Applications

AI workloads frequently have unpredictable demand.

For example, imagine a document-processing application:

  1. Users upload documents.
  2. Documents are placed into an Azure Service Bus queue.
  3. Containerized workers retrieve documents.
  4. Workers send documents to an AI service.
  5. Results are stored in a database.

During periods of low activity, perhaps only one worker is necessary.

During a large batch upload, hundreds or thousands of documents might be waiting.

A fixed number of replicas creates two problems:

Too few replicas

1 worker
├── Document 1
├── Document 2
├── Document 3
├── ...
└── Document 10,000

Processing becomes slow.

Too many replicas

20 workers
└── Almost nothing to process

Resources are unnecessarily consumed.

KEDA allows the application to dynamically respond to the workload.


4. KEDA Versus CPU-Based Autoscaling

A common exam scenario is determining whether resource-based scaling or event-based scaling is more appropriate.

Suppose a worker application consumes messages from Azure Service Bus.

CPU usage might look like this:

Queue MessagesCPU Usage
05%
10015%
1,00020%
10,00025%

CPU isn’t necessarily a good representation of the amount of work waiting.

KEDA can instead monitor the queue itself.

For example:

Target = 20 messages per replica
20 messages → 1 replica
40 messages → 2 replicas
100 messages → 5 replicas
200 messages → 10 replicas

This makes the scaling decision directly related to the workload.


5. KEDA Scalers

A KEDA scaler connects KEDA to an external event source or metric.

Azure Container Apps supports KEDA-based custom scaling rules for various event sources.

Common examples include:

  • Azure Service Bus
  • Azure Event Hubs
  • Apache Kafka
  • Redis
  • Azure Queue Storage
  • Other supported KEDA scalers through custom rules

Azure Container Apps also supports HTTP and TCP scaling rules, but these aren’t the same thing as event-driven KEDA scaling.

For the exam, remember:

HTTP scaling and event-driven scaling are different scaling mechanisms.


6. Container Apps Scale Rules

Scaling is configured through the container app’s scale configuration.

A scale configuration contains concepts such as:

  • minReplicas
  • maxReplicas
  • rules
  • polling interval
  • cooldown period

A simplified conceptual configuration looks like this:

scale:
minReplicas: 0
maxReplicas: 10
rules:
- name: service-bus-rule
type: azure-servicebus
metadata:
queueName: orders
messageCount: 20

The exact metadata depends on the KEDA scaler being used.

The important exam concept is the relationship:

Scale Rule
├── Scaler type
├── Metadata
└── Authentication
KEDA
Desired replicas

7. minReplicas

minReplicas specifies the minimum number of replicas that the application can maintain.

For example:

minReplicas = 1

means that the application won’t scale below one replica.

This is useful when:

  • The application must always be available.
  • Cold-start latency is undesirable.
  • The workload can’t tolerate scaling to zero.

By contrast:

minReplicas = 0

allows the application to scale down to zero when there is no workload.

Azure Container Apps supports a minimum of zero replicas and a maximum configurable replica count of up to 1,000.


8. maxReplicas

maxReplicas establishes the upper limit on scaling.

For example:

minReplicas: 0
maxReplicas: 20

means:

0 ≤ replicas ≤ 20

Even if the event source contains a massive backlog, the application won’t exceed the configured maximum.

This is important for:

  • Controlling costs
  • Protecting downstream services
  • Preventing excessive concurrency
  • Preventing an application from overwhelming a database or AI service

Exam tip

If a question asks:

“How can you prevent an event-driven application from creating an excessive number of replicas?”

Look for:

Configure maxReplicas.


9. Target Values and Scaling

Many KEDA scalers use a target value that represents the desired workload per replica.

For example, consider:

messageCount = 20

Conceptually, this means the scaler targets approximately 20 messages per replica.

If there are 100 messages:

Desired replicas = ceil(100 / 20)
Desired replicas = 5

Therefore:

100 messages
Target = 20 messages/replica
5 replicas

Azure Container Apps describes the general scaling calculation as:

desiredReplicas =
ceil(currentMetricValue / targetMetricValue)

subject to the configured scaling limits and Container Apps’ scaling behavior.


10. Example: Azure Service Bus

Suppose an AI application processes image-analysis requests from an Azure Service Bus queue.

The scaling rule specifies:

messageCount = 10
minReplicas = 0
maxReplicas = 10

The approximate relationship is:

MessagesDesired Replicas
00
1–101
11–202
21–303
51–606
91–10010
50010

The final example is limited by maxReplicas.

Therefore, even if 500 messages are waiting, the application won’t create 50 replicas when the maximum is 10.


11. Polling Interval

KEDA periodically checks the event source.

Azure Container Apps uses a default KEDA polling interval of 30 seconds for custom scale rules.

Conceptually:

T0
├── KEDA checks queue
T+30 sec
├── KEDA checks queue
T+60 sec
├── KEDA checks queue
...

This is important because event-driven scaling isn’t necessarily instantaneous.

If a question describes a workload that suddenly receives messages and asks why scaling doesn’t happen immediately, the polling interval may be relevant.


12. Cooldown Period

The cooldown period determines how long KEDA waits before scaling an application from its final active replica down to zero after the event source becomes inactive.

The default cooldown period for Container Apps custom scaling is 300 seconds.

For example:

Messages arrive
Scale out
Messages processed
Queue becomes empty
Cooldown period
Scale to zero

An important distinction is that the cooldown period specifically affects scaling from the final replica to zero; it isn’t simply a universal delay applied to every scale-in operation.


13. Scale-to-Zero

One of the major advantages of event-driven scaling is the ability to scale an application to zero.

For example:

No work
0 replicas
│ New event arrives
1 replica
More events
5 replicas

This is especially useful for workloads that aren’t continuously active.

Examples include:

  • Document processing
  • Image processing
  • AI inference jobs
  • Data enrichment
  • Background processing
  • Queue consumers

When the workload disappears, the application can eventually return to zero replicas.

Azure Container Apps doesn’t charge usage charges for a container app while it is scaled to zero.


14. Authentication for KEDA Scale Rules

A KEDA scaler often needs permission to inspect the external event source.

For example, a Service Bus scaler needs access to Service Bus.

Azure Container Apps supports authentication for scale rules using:

  • Secrets
  • Managed identities for supported Azure resources

The authentication configuration is associated with the scale rule rather than requiring application code to perform the scaling operation.

Managed identity

For Azure resources, managed identity is often preferable because the application doesn’t need to store a long-lived credential.

Conceptually:

Container App
│ Managed Identity
Microsoft Entra ID
Azure Service Bus

This is generally preferable to embedding credentials in application source code.


15. Secret-Based Authentication

Scale rules can also reference secrets.

Conceptually:

Container App
├── Secret
KEDA scale rule
Event source

For example, a Service Bus connection string could be stored as a Container Apps secret and referenced by the scale rule.

Exam distinction

Don’t confuse:

Application authentication

with:

Scaler authentication

The application itself may have its own credentials or managed identity, while KEDA separately needs authorization to inspect the event source.


16. Multiple Scaling Rules

A container app can have multiple scaling rules.

For example:

Container App
├── HTTP rule
├── Service Bus rule
└── Redis rule

When multiple rules are configured, the application scales when the first applicable scaling condition is met.

This means you can combine different workload signals.

For example:

HTTP traffic ────────┐
Service Bus backlog ─┼──► Scaling decision
Redis events ────────┘

17. KEDA and Azure Container Apps Revisions

A particularly important Azure Container Apps concept is that changing scaling rules creates a new revision of the container app. A revision is an immutable snapshot of the application configuration.

Conceptually:

Revision 1
├── Old scaling rules
Update scaling configuration
Revision 2
└── New scaling rules

This matters when managing production applications using revision-based deployment strategies.


18. KEDA and Dapr

KEDA can also be used with Dapr-based applications.

For example, an application could use Dapr pub/sub:

Publisher
Dapr Pub/Sub
Subscriber Container App
KEDA

KEDA can scale the subscriber based on pending events/messages.

In this scenario, KEDA can scale both the application and its Dapr sidecar based on the workload.


19. KEDA Versus Event-Driven Container Apps Jobs

Azure Container Apps supports both:

Container Apps

A container app normally maintains a number of replicas that continuously process work.

Queue
Container App
├── Replica 1
├── Replica 2
└── Replica 3

Event-driven Container Apps Jobs

An event can instead trigger individual job executions.

Queue
├── Event 1 ──► Job execution 1
├── Event 2 ──► Job execution 2
└── Event 3 ──► Job execution 3

Both use KEDA-based scaling concepts, but the result is different.

For an application, the scaling rule determines the number of replicas.

For an event-driven job, the scaling rule determines the number of job executions to start.

Exam tip

If the question says:

“Each event should result in a separate container execution.”

Consider an event-driven Container Apps Job rather than a continuously running container app.


20. KEDA Configuration Concepts to Know

For AI-200, be comfortable recognizing these concepts:

ConceptPurpose
ScalerConnects KEDA to an event source or metric
Scale ruleDefines how Container Apps uses a scaler
MetadataProvides scaler-specific configuration
AuthenticationAllows KEDA to access the event source
minReplicasLowest number of replicas
maxReplicasHighest number of replicas
Polling intervalHow frequently KEDA checks an event source
Cooldown periodDelay associated with scaling the final replica to zero
Scale-to-zeroAllows inactive applications to have zero replicas
ReplicaAn active instance of the container app revision

21. Example Architecture

Consider an AI document-classification system.

                         ┌──────────────────┐
                         │   Web/API App    │
                         └────────┬─────────┘
                                  │
                                  │ Submit document
                                  ▼
                         ┌──────────────────┐
                         │ Azure Service    │
                         │ Bus Queue        │
                         └────────┬─────────┘
                                  │
                           Pending messages
                                  │
                                  ▼
                         ┌──────────────────┐
                         │      KEDA        │
                         │     Scaler       │
                         └────────┬─────────┘
                                  │
                           Scaling decision
                                  │
                                  ▼
                    ┌─────────────────────────┐
                    │    Azure Container App  │
                    │                         │
                    │ ┌────┐ ┌────┐ ┌────┐   │
                    │ │ R1 │ │ R2 │ │ R3 │...│
                    │ └────┘ └────┘ └────┘   │
                    └───────────┬─────────────┘
                                │
                                ▼
                         Azure AI Service
                                │
                                ▼
                            Data Store

The important point is that KEDA doesn’t process the messages.

KEDA’s responsibility is to determine how many replicas should be running.

The application replicas are responsible for processing the messages.


22. Common Exam Scenarios

Scenario 1: Queue backlog

A containerized AI worker processes Service Bus messages. The application should automatically add workers as the queue backlog increases.

Use KEDA event-driven scaling.


Scenario 2: Scale to zero

The application should consume no running replicas when there are no messages.

Configure:

minReplicas = 0

and use an appropriate event-driven scale rule.


Scenario 3: Limit cost

A sudden event spike must not cause more than 20 workers.

Configure:

maxReplicas = 20

Scenario 4: Avoid stored credentials

KEDA needs access to an Azure Service Bus resource, and the organization doesn’t want connection strings stored.

Use an appropriate managed identity configuration.


Scenario 5: Separate execution per event

Each event should start an independent container execution.

Consider an event-driven Container Apps Job rather than a continuously running container app.


23. Common Mistakes to Avoid

Mistake 1: Installing KEDA manually

For Azure Container Apps, you don’t need to deploy your own KEDA installation.

Remember: Container Apps provides the KEDA integration.


Mistake 2: Assuming KEDA only works with Kubernetes clusters

KEDA originated in the Kubernetes ecosystem, but Azure Container Apps exposes KEDA functionality without requiring you to manage Kubernetes infrastructure.


Mistake 3: Confusing KEDA with CPU autoscaling

KEDA is particularly valuable when scaling should be driven by external events or metrics, such as queue length or event backlog.


Mistake 4: Forgetting maxReplicas

Without an appropriate maximum, a large workload can potentially result in substantial scale-out.

Always consider:

minReplicas
maxReplicas

Mistake 5: Assuming scaling is instantaneous

KEDA polls event sources. The default polling interval for custom Container Apps scaling rules is 30 seconds, so there can be a delay between a change in workload and the scaling decision.


Mistake 6: Confusing cooldown with polling

These are different:

Polling interval

How frequently KEDA checks the event source.

Cooldown period

How long KEDA waits before scaling the final replica to zero after the workload becomes inactive.


24. AI-200 Exam Takeaways

For the exam, make sure you can answer these questions:

What is KEDA?

A Kubernetes-based event-driven autoscaling mechanism used by Azure Container Apps to scale workloads based on external events and metrics.

Why use KEDA?

When application demand is better represented by an external event source—such as a queue backlog—than by CPU or memory utilization.

Do you install KEDA in Container Apps?

No. Azure Container Apps provides the KEDA integration.

What controls the minimum number of replicas?

minReplicas

What controls the maximum?

maxReplicas

What determines the type of event source?

The KEDA scaler type, such as:

azure-servicebus

What does scaler metadata provide?

The scaler-specific information needed to monitor the event source and determine scaling.

Can Container Apps scale to zero?

Yes, when configured appropriately, such as with minReplicas: 0.

What is the default polling interval?

30 seconds for custom KEDA scale rules.

What is the default cooldown period?

300 seconds for custom scaling, with the cooldown specifically applying to scaling from the final replica to zero.

What happens when multiple scale rules exist?

The application begins scaling when the condition for the first applicable rule is met.


Practice Exam Questions

Question 1

An AI application running in Azure Container Apps processes messages from an Azure Service Bus queue. The application should automatically increase the number of replicas when the number of pending messages increases.

Which technology should you use?

A. Kubernetes Event-driven Autoscaling (KEDA)
B. Azure Traffic Manager
C. Azure Front Door
D. Azure DNS

Answer: A

Explanation

KEDA is designed for event-driven autoscaling. In Azure Container Apps, KEDA can monitor supported event sources such as Azure Service Bus and adjust the number of application replicas according to the workload.

The other services are primarily concerned with traffic routing or DNS rather than workload-driven container scaling.


Question 2

You configure an Azure Container App with the following settings:

minReplicas: 0
maxReplicas: 10

The application uses a KEDA-based scale rule and currently has no events to process.

What is the expected minimum number of running replicas?

A. 0
B. 5
C. 1
D. 10

Answer: A

Explanation

minReplicas specifies the minimum number of replicas. Setting it to 0 permits the application to scale to zero when the workload is inactive.

This is one of the major benefits of event-driven scaling for intermittently used workloads.


Question 3

An AI worker consumes messages from an Azure Service Bus queue. The KEDA scale rule uses a target of 20 messages per replica. There are currently 100 messages waiting.

Ignoring scaling limits and other scaling behavior, approximately how many replicas does the target calculation request?

A. 2
B. 5
C. 20
D. 100

Answer: B

Explanation

The target calculation is conceptually:

desiredReplicas = ceil(currentMetricValue / targetMetricValue)
desiredReplicas = ceil(100 / 20)
desiredReplicas = 5

Therefore, the target is approximately 5 replicas.


Question 4

An organization wants to ensure that an event-driven Container App never scales beyond 25 replicas, even when a large backlog accumulates.

Which setting should you configure?

A. pollingInterval
B. cooldownPeriod
C. minReplicas
D. maxReplicas

Answer: D

Explanation

maxReplicas establishes the maximum number of replicas that the container app can use for the configured scaling configuration.

For this requirement, configure:

maxReplicas: 25

pollingInterval controls how frequently the event source is checked, while cooldownPeriod relates to scale-down behavior. minReplicas controls the lower bound.


Question 5

A developer wants KEDA in an Azure Container App to determine scaling based on the number of pending messages in Azure Service Bus.

Which component identifies the event source and its associated scaling behavior?

A. Azure Monitor workbook
B. Container Apps ingress configuration
C. KEDA scaler
D. Azure Load Balancer

Answer: C

Explanation

A KEDA scaler connects the autoscaling mechanism to an event source or external metric. The scaler type and associated metadata define how KEDA obtains the workload information.

Ingress and load-balancing configurations don’t provide this event-driven autoscaling capability.


Question 6

An application uses a KEDA custom scale rule in Azure Container Apps. The administrator wants to understand how frequently KEDA checks the external event source by default.

Which interval should the administrator expect?

A. 5 seconds
B. 30 seconds
C. 5 minutes
D. 15 minutes

Answer: B

Explanation

The default polling interval for custom KEDA scaling rules in Azure Container Apps is 30 seconds.

This means event-driven scaling isn’t necessarily evaluated continuously or instantaneously.


Question 7

An AI application uses an Azure Service Bus queue. The organization wants KEDA to access the Azure resource without storing a long-lived Service Bus credential in the application configuration.

Which approach is most appropriate?

A. Disable authentication for the scale rule
B. Store the credential in application source code
C. Use a managed identity where supported
D. Increase the maximum replica count

Answer: C

Explanation

Azure Container Apps supports managed identity authentication for supported Azure resource scale rules.

Managed identities allow Azure resources to authenticate without requiring application developers to embed long-lived credentials in source code or configuration.


Question 8

An event-driven Container App has finished processing its queue. The application currently has one replica, and the queue remains empty.

The application is configured with the default 300-second cooldown period.

What is the purpose of the cooldown period?

A. Determine how frequently the queue is polled
B. Determine the maximum number of replicas
C. Determine the target number of messages per replica
D. Delay scaling the final replica to zero after the workload becomes inactive

Answer: D

Explanation

The cooldown period is associated with scaling from the final active replica to zero.

For Container Apps custom scaling rules, the default cooldown period is 300 seconds.

It should not be confused with the polling interval, which determines how frequently KEDA checks the event source.


Question 9

An Azure Container App has two scaling rules:

  • An HTTP scaling rule
  • An Azure Service Bus KEDA scaling rule

The Service Bus queue suddenly contains a large backlog while HTTP traffic remains low.

What happens?

A. The application can scale based on the Service Bus rule
B. Only the HTTP rule is evaluated
C. The application must use CPU scaling instead
D. The two rules are averaged before scaling

Answer: A

Explanation

Azure Container Apps can have multiple scaling rules. The application begins scaling when the condition for an applicable rule is met.

Therefore, a Service Bus backlog can cause scaling even if HTTP traffic isn’t high enough to trigger the HTTP rule.


Question 10

A development team has a workload in which each incoming event should trigger a separate container execution. The workload doesn’t need a continuously running pool of worker replicas.

Which Azure Container Apps capability is the best fit?

A. HTTP ingress scaling
B. Event-driven Container Apps Jobs
C. Azure Traffic Manager
D. TCP ingress scaling

Answer: B

Explanation

Event-driven Container Apps Jobs are designed for workloads where events trigger individual job executions.

This differs from a normal Container App, where KEDA determines how many replicas of the application should be running to process the workload.

For example:

Event 1 → Job execution 1
Event 2 → Job execution 2
Event 3 → Job execution 3

A continuously running container application would instead maintain a pool of replicas that process events.


Final Exam Cheat Sheet

TopicKey Point
KEDAEvent-driven autoscaling
Azure Container Apps + KEDAKEDA integration is managed by Container Apps
Primary use caseScale based on external events/metrics
ExamplesService Bus, Event Hubs, Kafka, Redis
minReplicasMinimum replicas
maxReplicasMaximum replicas
minReplicas = 0Allows scale-to-zero
ScalerConnects KEDA to an event source
MetadataConfigures the scaler
AuthenticationSecrets or managed identity where supported
Default polling interval30 seconds
Default cooldown300 seconds
Target calculationceil(metric / target) conceptually
Multiple rulesScaling can begin when an applicable rule triggers
Scaling-rule changesCreate a new Container Apps revision
Container AppScales replicas
Event-driven Container Apps JobScales job executions
Primary benefitEfficient scaling based on actual workload
Major advantageCan scale inactive workloads to zero

The key idea to remember for AI-200 is simple: KEDA allows Azure Container Apps to scale containerized workloads according to events and external workload metrics rather than relying solely on traditional resource utilization such as CPU or memory.


Go to the AI-200 Exam Prep Hub main page

Deploy applications to Azure Container Apps, including environment configuration and revision management (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container application hosting
      --> Deploy applications to Azure Container Apps, including environment configuration and revision management


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Introduction

Azure Container Apps is a serverless container platform designed for running modern applications and microservices without requiring developers to manage the underlying Kubernetes infrastructure. For the AI-200 exam, developers should understand not only how to deploy a containerized application, but also how to configure its Container Apps environment, manage application settings, and use revisions to safely deploy and operate different versions of an application.

This topic is particularly important because Azure Container Apps separates the concepts of the application environment, the container application, and the revision. Understanding those boundaries makes many exam questions much easier to answer.


1. What Is Azure Container Apps?

Azure Container Apps provides a managed platform for running containerized applications while abstracting much of the infrastructure management associated with Kubernetes.

It is well suited for applications such as:

  • REST APIs
  • Web applications
  • Microservices
  • Background processing services
  • Event-driven applications
  • AI inference services
  • Containerized application backends

Unlike Azure Kubernetes Service, developers do not need to manage Kubernetes clusters, nodes, or the Kubernetes control plane.

Azure Container Apps can provide:

  • Containerized application hosting
  • Automatic scaling
  • Scale-to-zero capabilities
  • HTTP and TCP ingress
  • Service-to-service communication
  • Revisions and traffic splitting
  • Secrets and configuration
  • Managed identities
  • Dapr integration
  • Logging and monitoring
  • Workload profiles

For AI applications, Container Apps can be particularly useful for hosting APIs, inference services, orchestration components, and other containerized workloads.


2. Understand the Container Apps Environment

A Container Apps environment is a secure boundary around a group of Container Apps.

Multiple Container Apps can be deployed into the same environment. Apps within the same environment can share important infrastructure characteristics, including networking and logging. Microsoft describes the environment as a secure boundary for a group of container apps.

A useful mental model is:

Azure subscription → Resource group → Container Apps environment → Container Apps → Revisions

For example:

Subscription
└── Resource Group
└── Container Apps Environment
├── customer-api
│ ├── Revision 1
│ ├── Revision 2
│ └── Revision 3
├── recommendation-api
│ ├── Revision 1
│ └── Revision 2
└── document-processor
└── Revision 1

The environment therefore provides infrastructure-level isolation and shared capabilities, while the individual Container App represents an application or service running inside that environment.


3. Why the Environment Matters

When creating a Container App, you either select an existing Container Apps environment or create a new one.

Environment configuration can affect:

  • Networking
  • Logging
  • Workload profiles
  • Application isolation
  • Communication between applications
  • Infrastructure configuration

For example, applications deployed into the same environment can communicate with one another using Container Apps’ internal networking capabilities.

The environment can also be associated with logging infrastructure such as a Log Analytics workspace.

Exam Tip

If a question says that several Container Apps need to share a common environment, networking boundary, or logging configuration, think about the Container Apps environment rather than creating separate environments for every application.


4. Creating a Container App

A typical deployment involves the following conceptual steps:

  1. Create or select a resource group.
  2. Create or select a Container Apps environment.
  3. Specify the container image.
  4. Configure compute resources.
  5. Configure environment variables and secrets.
  6. Configure ingress if the application needs to receive traffic.
  7. Configure scaling.
  8. Deploy the application.
  9. Monitor the resulting revision.

For example, Azure CLI can deploy an existing container image with a command conceptually similar to:

az containerapp create \
--name my-container-app \
--resource-group my-resource-group \
--environment my-container-environment \
--image myregistry.azurecr.io/myapp:v1 \
--target-port 80 \
--ingress external

The important exam concept is not memorizing the exact command syntax. Instead, understand which configuration belongs to the environment and which belongs to the Container App.


5. Container App Configuration vs. Revision Configuration

One of the most important concepts for AI-200 is that not every change to a Container App creates a new revision.

Azure Container Apps distinguishes between:

Revision-scope changes

These changes define the version of the application and result in a new revision.

Examples include changes to:

  • Container image
  • Container configuration
  • Container resources
  • Environment variables associated with the container template
  • Scale configuration
  • Scale rules
  • Container commands and arguments
  • Probes
  • Volumes and mounts
  • Revision suffix

The Container Apps API documentation describes the template as the versioned application definition, and changes to the template result in a new immutable revision.

Application-scope changes

These changes affect the Container App configuration rather than creating a new version of the application.

Examples include:

  • Revision mode
  • Ingress configuration
  • Traffic rules
  • Secrets
  • Registry credentials
  • Dapr configuration
  • Other application-level configuration

These settings apply to the application rather than representing a new immutable revision.

Exam shortcut

When deciding whether a change creates a revision, ask:

Does this change define the versioned application template?

If yes, it is generally a revision-scope change.

If it changes how the application is configured or exposed without changing the application template, it is generally an application-scope change.


6. What Is a Revision?

A revision is an immutable snapshot of a Container App’s versioned configuration.

Think of a revision as a deployable version of the application.

For example:

customer-api
├── Revision 1 → v1 container image
├── Revision 2 → v2 container image
└── Revision 3 → v3 container image

Once created, a revision is immutable.

If you change the container image from:

myapp:v1

to:

myapp:v2

Azure Container Apps creates a new revision rather than modifying the existing revision.

This provides an important deployment-management capability:

A deployed revision represents a known version of the application.

Microsoft’s documentation describes revisions as immutable, versioned snapshots that can remain available for rollback, testing, or traffic management.


7. Why Revisions Are Important

Revisions provide several important capabilities.

Version management

You can identify different versions of an application.

Safe deployments

A new revision can be deployed without immediately replacing the existing version in multiple-revision scenarios.

Rollbacks

If a new version fails, traffic can be directed back to a previous revision.

A/B testing

Different revisions can receive different percentages of traffic.

Blue-green deployments

One revision can serve production traffic while another is deployed and validated before switching traffic.

Testing

A new revision can be tested before directing production traffic to it.

These capabilities make revisions particularly valuable for AI applications where changes to models, inference code, prompts, dependencies, or APIs may need controlled deployment.


8. Single Revision Mode

Azure Container Apps supports single revision mode and multiple revision mode. Single revision mode is the default.

In single revision mode:

  • Only one revision is active at a time.
  • A new revision is created when a revision-scoped change is deployed.
  • Azure manages the transition from the old revision to the new revision.
  • Traffic moves to the new revision after it is ready.
  • The old revision is eventually deprovisioned.

This mode is useful when the desired deployment model is essentially:

“Deploy the new version and replace the old version.”

For example:

Before deployment:
100% traffic
Revision 1
After deployment:
100% traffic
Revision 2

9. Zero-Downtime Deployment

Single revision mode is designed to avoid unnecessary downtime during deployment.

When a new revision is created, the existing revision continues serving traffic while the new revision is provisioned.

The new revision must become ready before traffic is moved.

Readiness involves factors such as:

  • Successful provisioning
  • Required replicas becoming available
  • Startup probes passing
  • Readiness probes passing

Therefore, if a new revision fails to become ready, the existing revision can continue serving traffic rather than immediately being replaced.

Exam scenario

Suppose:

  • Revision 1 is healthy.
  • Revision 2 is deployed.
  • Revision 2 fails its readiness checks.

The safest answer is generally that Revision 1 continues receiving traffic in single revision mode while Revision 2 fails to become ready.


10. Multiple Revision Mode

Multiple revision mode allows multiple revisions to remain active simultaneously.

This provides significantly more control over deployments.

For example:

                 ┌── Revision 1 ── 80%
Incoming traffic ┤
                 └── Revision 2 ── 20%

This is useful for:

  • A/B testing
  • Canary releases
  • Blue-green deployments
  • Gradual rollouts
  • Testing a new application version
  • Maintaining multiple application versions

Microsoft’s traffic-splitting functionality allows traffic to be distributed among active revisions using percentage weights. The total traffic allocation must equal 100%.


11. Traffic Splitting

In multiple revision mode, traffic can be divided among revisions.

For example:

Revision 1 → 90%
Revision 2 → 10%

This means approximately 90% of incoming traffic is routed to Revision 1 and 10% to Revision 2.

A common deployment strategy is to gradually increase the percentage assigned to the new revision:

Stage 1
v1 = 100%
v2 = 0%
Stage 2
v1 = 90%
v2 = 10%
Stage 3
v1 = 50%
v2 = 50%
Stage 4
v1 = 0%
v2 = 100%

This provides a controlled rollout.

Important exam point

Traffic weights must add up to 100%.

For example:

Revision A = 70%
Revision B = 30%

is valid.

But:

Revision A = 70%
Revision B = 20%

does not fully allocate traffic.


12. Revision Labels

Revision labels provide a way to identify a particular revision with a meaningful name.

Instead of relying entirely on an automatically generated revision name, a developer can use a label representing an environment or deployment stage.

For example:

staging
production

A labeled revision can be accessed through a label-specific endpoint.

Labels can be useful when:

  • Testing a specific revision
  • Maintaining a staging version
  • Providing direct access to a particular revision
  • Performing deployment workflows
  • Separating testing traffic from production traffic

Azure CLI provides commands for managing revision labels, including adding, removing, and swapping labels.


13. Revision Names and Suffixes

Azure Container Apps automatically generates revision names, but developers can provide a meaningful revision suffix.

For example:

customer-api-v2

could be represented conceptually by a Container App named:

customer-api

with a revision suffix such as:

v2

Meaningful revision naming can make deployment management easier.

Good naming can help identify:

  • Application version
  • Deployment stage
  • Release identifier
  • Build number
  • Feature release

However, revision names and suffixes have naming restrictions, so applications should follow Azure’s supported naming rules rather than assuming arbitrary strings are valid.


14. Deploying a New Revision

A new revision is created when a revision-scope property changes.

For example, changing:

image = myregistry.azurecr.io/customer-api:v1

to:

image = myregistry.azurecr.io/customer-api:v2

creates a new revision.

Conceptually:

Revision 1
Image: customer-api:v1
│ deploy image v2
Revision 2
Image: customer-api:v2

Revision 1 remains an independent immutable version.

This is one of the most important concepts to understand for exam questions involving deployments.


15. Rollbacks

Suppose Revision 2 introduces a serious problem:

Revision 1 → stable
Revision 2 → defective

In a multiple-revision deployment, traffic can be redirected back to Revision 1.

For example:

Before rollback:
Revision 1 → 20%
Revision 2 → 80%
After rollback:
Revision 1 → 100%
Revision 2 → 0%

The existing revision doesn’t need to be rebuilt because the previous revision already represents the known-good application version.

This is one of the primary benefits of immutable revisions.


16. Blue-Green Deployments

Azure Container Apps revisions can be used to implement a blue-green deployment strategy.

For example:

BLUE
Revision 1
Production
100% traffic
GREEN
Revision 2
New version
0% traffic

The new revision can be tested while receiving no production traffic.

Once validation is complete:

BLUE → 0%
GREEN → 100%

The new version becomes the production version.

If a problem occurs:

BLUE → 100%
GREEN → 0%

This provides a fast rollback mechanism.


17. Canary Deployments

Multiple revisions can also support a canary release.

For example:

Stable revision → 95%
New revision → 5%

Only a small percentage of users initially reach the new version.

If the new version performs well, the deployment can gradually increase its traffic allocation:

95/5
80/20
50/50
20/80
0/100

This is especially useful for AI applications because a new model or inference implementation can be exposed to a limited portion of traffic before being fully deployed.


18. Scaling and Revisions

Scaling configuration can also be revision-scoped.

For example, a Container App might use:

Minimum replicas: 1
Maximum replicas: 10

and scale based on HTTP concurrency.

Changing the application’s scale configuration can result in a new revision because scale settings are part of the versioned template.

This is important because two revisions can potentially have different scaling configurations.

For example:

Revision 1
min replicas = 1
max replicas = 5
Revision 2
min replicas = 2
max replicas = 20

In multiple revision mode, these revisions can coexist with their respective configurations.


19. Ingress Configuration

Ingress determines how network traffic reaches a Container App.

Depending on the application, ingress can be:

  • External
  • Internal

External ingress makes the application accessible from outside the environment.

Internal ingress is useful when the application should only be reachable from within the environment or associated network configuration.

Container Apps supports HTTP and TCP-oriented ingress scenarios, with HTTP/1.1, HTTP/2, and TCP transport options depending on the configuration and workload.

Exam clue

If a question asks:

“The application must be accessible from the public internet.”

Look for an external ingress configuration.

If it asks:

“The API should only be accessible by other applications inside the Container Apps environment.”

Look for internal ingress.


20. Environment Variables

Containerized applications frequently require configuration values such as:

ENVIRONMENT=Production
MODEL_NAME=my-model
API_ENDPOINT=https://example

These values can be provided as environment variables.

Environment variables are part of the container configuration and therefore can be associated with a revision.

For example:

Revision 1
API_ENDPOINT = endpoint-v1
Revision 2
API_ENDPOINT = endpoint-v2

This is important when different application versions need different configuration.


21. Secrets

Sensitive information should not be hard-coded into container images.

Examples include:

  • API keys
  • Passwords
  • Connection strings
  • Tokens
  • Credentials

Azure Container Apps supports secrets that can be referenced by container environment variables.

Conceptually:

Container
└── Environment variable
└── secretRef
Container App Secret

The Container Apps API supports environment variables that reference Container App secrets using secretRef.

For more advanced secret-management requirements, Azure Key Vault can be used rather than embedding credentials directly in the application.

Exam Tip

If the question asks where to store a password or API key, do not choose a Dockerfile or hard-coded environment variable.

Think:

Secret management → Container Apps secrets / Azure Key Vault


22. Private Container Registries

Container Apps can deploy images from private container registries.

For example:

Azure Container Registry
│ image
Azure Container Apps

The Container App must have appropriate authorization to pull the image.

For Azure-hosted workloads, managed identities can often be used to avoid embedding long-lived credentials.

This follows an important security principle:

Prefer identity-based authentication over hard-coded credentials.


23. Container Apps and Azure Container Registry

A common AI-200 deployment architecture is:

Developer
Build container image
Azure Container Registry
Azure Container Apps
├── Revision 1
└── Revision 2

Azure Container Registry stores the container image while Azure Container Apps runs the container.

A new image version can then be deployed as a new revision.

For example:

my-ai-api:v1
my-ai-api:v2
my-ai-api:v3

Each deployment can correspond to a new revision.


24. Environment Configuration vs. Revision Management

A useful exam distinction is:

ConceptPurpose
Container Apps environmentShared boundary and infrastructure context
Container AppThe application/service
RevisionImmutable version of the application
Revision modeDetermines how revisions are activated
IngressControls how traffic reaches the application
Traffic splittingDetermines how traffic is distributed
Revision labelProvides identifiable access to a revision
SecretStores sensitive configuration
Environment variableSupplies application configuration
Scale configurationDetermines how the application responds to demand

Understanding these distinctions helps prevent choosing an answer that sounds plausible but operates at the wrong level.


25. A Typical Deployment Lifecycle

A production deployment might look like this:

Step 1 — Build

Create the container image.

AI application source
Docker build
Container image

Step 2 — Store

Push the image to Azure Container Registry.

Container image
Azure Container Registry

Step 3 — Deploy

Deploy the image to Azure Container Apps.

Registry
Container App
Revision 1

Step 4 — Update

Deploy a new image.

Registry
Container App
Revision 2

Step 5 — Validate

Check:

  • Provisioning state
  • Running state
  • Replica health
  • Application logs
  • Health probes
  • Application metrics

Step 6 — Route traffic

In multiple revision mode:

Revision 1 → 90%
Revision 2 → 10%

Step 7 — Complete rollout

If the new revision is healthy:

Revision 1 → 0%
Revision 2 → 100%

Step 8 — Roll back if necessary

If problems appear:

Revision 1 → 100%
Revision 2 → 0%

This workflow illustrates why revisions are such an important Azure Container Apps capability.


26. Common Exam Traps

Trap 1: Assuming every configuration change creates a revision

Not every change creates a new revision.

Remember the distinction between revision-scope and application-scope configuration.


Trap 2: Assuming revisions are mutable

Revisions are immutable.

To change the versioned application configuration, deploy a new revision.


Trap 3: Confusing single and multiple revision modes

Single mode is designed around one active revision.

Multiple mode allows several revisions to be active simultaneously.


Trap 4: Using traffic splitting in single mode

Traffic splitting requires multiple active revisions.

If the question specifically requires distributing traffic between two versions, look for multiple revision mode.


Trap 5: Assuming a failed new revision automatically replaces the healthy one

Azure Container Apps provides mechanisms that help maintain availability during deployment. In single revision mode, the existing revision can continue serving traffic while the new revision is being prepared.


Trap 6: Confusing a Container Apps environment with a Container App

The environment is the broader hosting boundary.

The Container App is the actual application.

Multiple Container Apps can exist within an environment.


Trap 7: Hard-coding secrets into a container

Passwords and API keys should not be placed directly into application code or container images.

Use appropriate secret-management capabilities.


Trap 8: Forgetting that scale configuration can be revision-specific

Scale configuration belongs to the versioned application template and can therefore create a new revision when changed.


27. AI-200 Exam Summary

For the AI-200 exam, remember these core points:

  1. Azure Container Apps provides managed hosting for containerized applications.
  2. A Container Apps environment provides a secure boundary for a group of Container Apps.
  3. Multiple Container Apps can share the same environment.
  4. A revision represents an immutable version of a Container App.
  5. Changes to revision-scoped properties create new revisions.
  6. Application-scoped changes don’t create new revisions.
  7. Single revision mode is the default.
  8. Multiple revision mode allows multiple active revisions.
  9. Traffic can be split between active revisions in multiple mode.
  10. Traffic weights must total 100%.
  11. Revisions support blue-green deployments.
  12. Revisions support canary and A/B testing scenarios.
  13. Previous revisions can provide a convenient rollback target.
  14. Revision labels can provide meaningful access to particular revisions.
  15. Environment variables provide application configuration.
  16. Secrets should be used for sensitive values.
  17. Container Apps can pull images from container registries such as Azure Container Registry.
  18. Managed identities can reduce the need for embedded credentials.
  19. Ingress determines how applications receive network traffic.
  20. Health probes and application readiness are important during deployment.
  21. Scaling configuration can be revision-specific.
  22. Understanding the difference between environment, application, revision, and traffic configuration is essential for scenario-based questions.

Practice Exam Questions

Question 1

You deploy a container app named orders-api using revision 1. You then change the container image from orders:v1 to orders:v2.

What happens when the change is deployed?

A. Revision 1 is modified in place.

B. A new revision is created containing the new container image.

C. The Container Apps environment is recreated.

D. The application is automatically moved to another region.

Answer: B

Explanation

The container image is part of the versioned container template. Changing the image is therefore a revision-scope change, which causes a new immutable revision to be created. Revision 1 remains unchanged. Azure’s Container Apps API identifies the container template as versioned and states that changes to it create a new revision.


Question 2

An organization has three Container Apps that need to share a common networking boundary and logging infrastructure.

What should you create?

A. A separate revision for each application.

B. A single Container Apps environment containing the three applications.

C. A single container image containing all three applications.

D. A separate Azure Kubernetes Service cluster for each application.

Answer: B

Explanation

A Container Apps environment provides a secure boundary around a group of Container Apps. Applications within the same environment can share environment-level capabilities such as networking and logging.


Question 3

You need to gradually introduce a new version of an API. Initially, 95% of requests should go to the existing revision and 5% should go to the new revision.

Which configuration should you use?

A. Single revision mode with an environment variable.

B. A new Container Apps environment.

C. Multiple revision mode with traffic splitting.

D. A second container inside the same revision.

Answer: C

Explanation

Multiple revision mode allows multiple revisions to remain active simultaneously and supports percentage-based traffic splitting. This makes it appropriate for gradual or canary deployments.


Question 4

A Container App is currently configured in single revision mode. A developer deploys a new revision, but the new revision fails its readiness checks.

What is the expected behavior?

A. The existing healthy revision can continue serving traffic while the new revision fails to become ready.

B. All revisions are immediately deactivated.

C. The environment is automatically deleted.

D. Traffic is automatically divided equally between the failed and healthy revisions.

Answer: A

Explanation

In single revision mode, Azure Container Apps maintains the existing revision while the new revision is being provisioned. The new revision must become ready before traffic is moved to it. This helps support zero-downtime deployments.


Question 5

You need to deploy a new revision for testing while keeping the current production revision at 100% traffic. The test revision should remain available so developers can test it directly.

Which approach is most appropriate?

A. Use single revision mode and delete the production revision.

B. Create a second Container Apps environment and duplicate the application.

C. Modify the existing production revision in place.

D. Use multiple revision mode and keep the test revision active with appropriate traffic allocation or a revision label.

Answer: D

Explanation

Multiple revision mode allows several revisions to remain active. A revision can also be associated with a label to provide direct access to a particular revision. This is useful for staging and testing scenarios without immediately shifting production traffic.


Question 6

A developer changes an application’s revision mode from Single to Multiple.

Does changing the revision mode itself create a new revision?

A. Yes. Every configuration change creates a revision.

B. Yes, but only if traffic splitting is also configured.

C. No. Revision mode is an application-scope configuration.

D. No, because revision mode is stored in the container image.

Answer: C

Explanation

Revision mode is an application-scope configuration setting. Changing the revision mode does not itself create a new revision. Azure’s current API documentation identifies activeRevisionsMode as part of the non-versioned Container App configuration.


Question 7

An application has two active revisions configured with traffic weights of 70% and 20%.

What is wrong with this configuration?

A. Traffic splitting can only be 50/50.

B. Traffic weights must total 100%.

C. Multiple revision mode only supports two revisions.

D. Traffic splitting requires three revisions.

Answer: B

Explanation

Traffic weights define the percentage of incoming traffic routed to each revision. The combined weights must equal 100%. A 70% + 20% configuration accounts for only 90% of traffic.


Question 8

An AI inference API stores an Azure OpenAI API key in its container image.

What is the best improvement?

A. Move the key into a Dockerfile argument.

B. Put the key into the container image as an encrypted text file.

C. Store the key in a Container Apps secret or an appropriate external secret-management service such as Azure Key Vault.

D. Put the key directly into the application’s source code.

Answer: C

Explanation

Secrets such as API keys and passwords should not be embedded in source code or container images. Container Apps supports secrets that can be referenced by environment variables, while Azure Key Vault provides centralized secret management for more advanced scenarios. The Container Apps API supports secretRef for connecting environment variables to Container App secrets.


Question 9

You are implementing a blue-green deployment. Revision 1 is currently serving production traffic. Revision 2 contains a new version that has been fully tested.

What should you do to switch production to Revision 2 while retaining the ability to quickly roll back?

A. Delete Revision 1 immediately.

B. Update Revision 1 so it contains Revision 2’s code.

C. Create a new Container Apps environment and redirect DNS.

D. Shift production traffic from Revision 1 to Revision 2 while keeping Revision 1 available.

Answer: D

Explanation

Revisions are immutable versions of an application. A blue-green deployment can maintain the existing revision while the new revision is validated. Production traffic can then be shifted to the new revision. Keeping the previous revision available provides a straightforward rollback target if problems occur.


Question 10

You have an application running in multiple revision mode:

Revision A → 80%
Revision B → 20%

You change the container image used by Revision B.

What should you expect?

A. Revision B is modified in place while retaining its existing revision identity.

B. The Container Apps environment is recreated.

C. A new revision is created containing the changed container image.

D. Revision A is automatically deleted.

Answer: C

Explanation

The container image is part of the revision’s versioned template. Changing it creates a new revision rather than modifying the existing immutable revision. The new revision can then be activated and assigned traffic according to the application’s revision configuration.


Final Exam Takeaway

The easiest way to reason about Azure Container Apps deployment questions is to think in terms of layers:

CONTAINER APPS ENVIRONMENT
│ Shared hosting/networking boundary
CONTAINER APP
│ Application configuration
REVISION
│ Immutable version
CONTAINER IMAGE + TEMPLATE + SCALE CONFIGURATION

Then ask:

Does the question involve the hosting boundary?
→ Think Container Apps environment.

Does it involve the application itself?
→ Think Container App configuration.

Does it change the versioned application template?
→ Think new revision.

Does it require multiple versions to run simultaneously?
→ Think multiple revision mode.

Does it require controlled percentages of traffic?
→ Think traffic splitting.

Does it require a gradual rollout?
→ Think canary deployment.

Does it require switching between old and new versions?
→ Think blue-green deployment.

Does it require returning to a known-good version?
→ Think previous revision and rollback.

Mastering those distinctions will cover a substantial portion of the scenario-based questions you are likely to encounter around deploying applications to Azure Container Apps for AI-200.


Go to the AI-200 Exam Prep Hub main page

Deploy containers to Azure App Service, including configuring App Service to supply environment variables and secrets (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container application hosting
      --> Deploy containers to Azure App Service, including configuring App Service to supply environment variables and secrets


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Azure App Service is a fully managed platform-as-a-service (PaaS) offering that allows developers to host web applications, APIs, and containerized applications without managing the underlying virtual machines or operating system.

For the AI-200: Developing AI Cloud Solutions on Azure exam, you should understand how to deploy a container image to App Service and, importantly, how to configure the application so that the container receives the configuration, environment variables, and secrets it needs at runtime.

This is particularly important for AI applications because containerized AI workloads commonly need configuration values such as:

  • Azure AI service endpoints
  • Model deployment names
  • Database connection information
  • Storage account names
  • Service Bus configuration
  • Application Insights configuration
  • Feature flags
  • API keys or other secrets

A well-designed application should not bake these values into the container image. Instead, configuration should be supplied by the hosting environment, with sensitive values preferably retrieved from a secure secret store such as Azure Key Vault.


1. Understand Azure App Service for Containers

Azure App Service can run applications packaged as custom container images. This allows developers to use their own runtime, dependencies, libraries, and operating-system configuration instead of relying exclusively on App Service’s built-in application stacks.

A typical architecture looks like this:

Developer → Container Image → Container Registry → Azure App Service → Running Container

For example:

  1. A developer creates a Dockerfile.
  2. The Dockerfile is used to build an image.
  3. The image is pushed to Azure Container Registry.
  4. App Service is configured to use that image.
  5. App Service pulls the image.
  6. App Service starts the container.
  7. App Service supplies configuration values as environment variables.
  8. The application reads those values at runtime.

App Service pulls the configured container image when the application starts. If an updated image is pushed to the registry, restarting the application causes App Service to pull the updated image.

This separation between the application image and the application configuration is an important concept for the exam.


2. Why Use Containers with App Service?

A custom container is useful when the application’s requirements don’t fit cleanly into one of App Service’s predefined runtime stacks.

For example, an AI application might require:

  • A particular Python version
  • Specific native libraries
  • Custom machine-learning packages
  • A specialized web server
  • OS-level dependencies
  • A combination of packages that isn’t available in a standard App Service stack

Instead of configuring all those dependencies on the App Service platform, you can package them into a container.

Key benefit

The container provides a consistent application environment.

The same image can potentially be used in:

  • Development
  • Testing
  • Staging
  • Production
  • Other container-hosting environments

This supports the important principle:

Build the application once and configure it differently for each environment.

The container should contain the application and its dependencies—not environment-specific secrets.


3. The Container Image and App Service Are Separate Concerns

One of the most important concepts to understand is the difference between the container image and the App Service configuration.

Container image

The image contains things such as:

  • Application code
  • Runtime
  • Dependencies
  • Libraries
  • System packages
  • Startup configuration

App Service configuration

App Service supplies environment-specific information such as:

  • Database endpoints
  • API endpoints
  • Feature flags
  • Environment names
  • Secret references
  • Connection information

This allows the same image to run in multiple environments.

For example:

Container Image
|
+-- Application code
+-- Python runtime
+-- Required libraries
+-- AI SDKs
|
v
App Service
|
+-- ENVIRONMENT=Production
+-- AI_ENDPOINT=...
+-- MODEL_NAME=...
+-- DATABASE_CONNECTION=...
+-- API_KEY=<Key Vault reference>

The application doesn’t need a different Docker image simply because it is moving from development to production.


4. Deploying a Container to App Service

There are several ways to deploy a containerized application to App Service.

A common approach is:

Dockerfile
docker build
Container Image
Azure Container Registry
Azure App Service

For example, a container image might be named:

myregistry.azurecr.io/my-ai-api:v1

The registry name identifies the container registry.

The repository identifies the application:

my-ai-api

And the tag identifies a particular version:

v1

Therefore:

myregistry.azurecr.io/my-ai-api:v1

identifies a specific container image.


5. Configure the Container Image

When creating or configuring an App Service application, you specify the container image that App Service should run.

For an image hosted in Azure Container Registry, App Service needs access to the registry.

For a private registry, authentication must be configured.

Depending on the scenario, App Service can use authentication mechanisms such as managed identity rather than embedding registry credentials. Current App Service configuration also supports managed-identity-based access to Azure Container Registry, which is generally preferable to managing long-lived registry passwords.

Exam concept

When you see a question asking for the most secure way to allow App Service to pull a private image from Azure Container Registry, consider:

Managed identity and appropriate Azure role assignments

rather than storing a registry password in application configuration.


6. The Container’s Listening Port

A containerized application must listen on the appropriate port so App Service can route traffic to it.

For custom containers, the port configuration is particularly important.

For example, suppose the application listens on:

8080

The application inside the container needs to listen on that port, and App Service needs to know which port to use.

A common App Service configuration is:

WEBSITES_PORT=8080

The WEBSITES_PORT application setting tells App Service which port the custom container is listening on. Microsoft specifically identifies WEBSITES_PORT as required for custom-container port configuration.

Example

Suppose the Dockerfile contains:

EXPOSE 8080

The application should also actually listen on port 8080.

Then App Service can be configured with:

WEBSITES_PORT = 8080

Important distinction

EXPOSE in a Dockerfile documents the port the container expects to use. It does not by itself guarantee that the application is actually listening on that port.

A common troubleshooting scenario is:

The container starts successfully, but the application isn’t reachable.

One of the first things to verify is whether the application is listening on the expected port and whether WEBSITES_PORT is configured correctly.


7. Environment Variables in App Service

App Service application settings are exposed to applications as environment variables.

This is one of the most important concepts for this exam topic.

For example, you could configure:

ENVIRONMENT = Production
MODEL_NAME = gpt-4o-mini
AI_ENDPOINT = https://example.openai.azure.com/

Your application can then read these values from its environment.

For Linux applications and custom containers, App Service passes application settings into the container as environment variables. Changes to App Service settings cause the application to restart.

This allows the application code to remain environment-independent.


8. Why Environment Variables Are Better Than Hard-Coding Configuration

Consider this application code:

AI_ENDPOINT = "https://production-ai.example.com"

This is problematic because the endpoint is embedded in the application.

A better approach is:

import os
AI_ENDPOINT = os.environ["AI_ENDPOINT"]

Then App Service supplies:

AI_ENDPOINT=https://production-ai.example.com

The same container can then be deployed elsewhere with:

AI_ENDPOINT=https://development-ai.example.com

without rebuilding the image.

This supports:

  • Environment portability
  • Easier deployments
  • Configuration management
  • Separation of code and configuration
  • Safer secret handling

9. Configure Application Settings

App Service application settings can be configured through the Azure portal, Azure CLI, PowerShell, ARM/Bicep, or other deployment mechanisms.

In the Azure portal, application settings are managed under the app’s environment/configuration settings.

For example, you might define:

SettingExample valueSensitive?
APP_ENVIRONMENTProductionNo
AI_ENDPOINThttps://my-ai.openai.azure.com/Usually no
MODEL_NAMEchat-modelNo
LOG_LEVELInformationNo
DATABASE_CONNECTIONConnection informationPotentially
API_KEYSecret valueYes

App Service stores app settings encrypted at rest. However, for secrets that require centralized secret management, Microsoft recommends using Azure Key Vault references rather than directly storing the secret value in the App Service setting.


10. Secrets Should Not Be Baked into Container Images

This is a major security principle.

Avoid putting something like this in a Dockerfile:

ENV API_KEY="abc123secret"

Also avoid:

API_KEY = "abc123secret"

Why?

Because the secret can potentially become part of the image or source code and therefore propagate into:

  • Container registries
  • Image layers
  • Source repositories
  • Build systems
  • Developer machines
  • Backups
  • Logs

Instead:

Container Image
+
App Service Configuration
+
Azure Key Vault

should provide the necessary runtime configuration.


11. Azure Key Vault Integration

Azure Key Vault provides centralized management for secrets, keys, and certificates.

For App Service, Key Vault can be integrated using Key Vault references.

Instead of putting the actual secret into an App Service setting, the setting contains a reference to the secret.

Conceptually:

API_KEY
@Microsoft.KeyVault(...)
Azure Key Vault
Secret value
Application

The application can consume the resolved value as an ordinary environment variable.

One of the major benefits is that application code doesn’t need to contain Key Vault-specific retrieval logic just to consume a referenced application setting.


12. Key Vault References

A Key Vault reference has a format similar to:

@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/mysecret)

Alternatively, a reference can use the vault and secret names:

@Microsoft.KeyVault(VaultName=myvault;SecretName=mysecret)

A specific secret version can also be specified.

For example:

AI_API_KEY =
@Microsoft.KeyVault(VaultName=myvault;SecretName=AI-API-Key)

The application can continue to access the setting using the environment variable:

AI_API_KEY

The application doesn’t have to know that the value originated from Key Vault.


13. Managed Identity and Key Vault

For Key Vault references to work securely, App Service needs an identity that can access the Key Vault.

A recommended architecture is:

Azure App Service
|
| Managed Identity
|
v
Azure Key Vault
|
v
Secret

The application does not need to store a Key Vault username/password or service principal secret.

App Service Key Vault references use the app’s system-assigned managed identity by default, although a user-assigned managed identity can also be configured. The identity must have permission to read secrets from the vault. With Azure RBAC, the Key Vault Secrets User role is an appropriate role for reading secrets.


14. System-Assigned vs. User-Assigned Managed Identity

You should understand the difference for exam questions.

System-assigned managed identity

The identity is tied to the Azure resource.

For example:

App Service
|
+-- System-assigned identity

If the App Service is deleted, the identity is also deleted.

User-assigned managed identity

The identity is a separate Azure resource.

User-assigned identity
|
+---- App Service A
|
+---- App Service B

It can therefore be reused by multiple resources.

Exam consideration

If a scenario specifically requires an identity to exist before the application is created or requires reuse across several resources, a user-assigned managed identity may be more appropriate.


15. Key Vault Secret Rotation

Key Vault references can simplify secret rotation.

When a Key Vault reference doesn’t specify a particular secret version, App Service can use the latest version of the secret.

App Service caches Key Vault reference values and periodically refreshes them. Microsoft documents a refresh interval of up to 24 hours; configuration changes that restart the app can cause the references to be fetched immediately.

This is an important distinction:

Changing the secret in Key Vault does not necessarily mean that the application immediately receives the new value.

If an application must immediately consume a new value, you need to account for the Key Vault reference refresh behavior.


16. What Happens When a Key Vault Reference Fails?

Suppose App Service has:

AI_API_KEY =
@Microsoft.KeyVault(VaultName=myvault;SecretName=AI-Key)

but the managed identity doesn’t have permission to retrieve the secret.

The reference might fail to resolve.

Potential causes include:

  • Incorrect Key Vault name
  • Incorrect secret name
  • Secret deleted
  • Incorrect reference syntax
  • Managed identity not enabled
  • Missing Key Vault permissions
  • Network restrictions preventing access to Key Vault

App Service provides Key Vault reference resolution information that can help diagnose these problems.

Exam clue

If a question says:

The application receives the literal @Microsoft.KeyVault(...) value instead of the expected secret.

Think:

The Key Vault reference failed to resolve.

Then investigate identity, permissions, reference syntax, secret existence, and networking.


17. App Settings vs. Key Vault

A useful exam distinction is:

RequirementRecommended approach
Non-sensitive configurationApp Service application setting
Environment-specific valueApp Service application setting
Secret valueAzure Key Vault
Secret consumed as an environment variableKey Vault reference in an App Service setting
Shared centralized configurationAzure App Configuration
Application codeDo not hard-code secrets

App Service application settings are appropriate for ordinary configuration.

Key Vault should be preferred when the value is a secret requiring centralized secret management, access control, auditing, and rotation.


18. App Configuration vs. Key Vault

AI-200 also covers Azure App Configuration, so understand how it differs from Key Vault.

Azure App Configuration

Designed primarily for centralized application configuration.

Examples:

Feature flags
Application settings
Environment configuration
Dynamic configuration

Azure Key Vault

Designed for sensitive information such as:

Passwords
API keys
Connection secrets
Certificates
Cryptographic keys

A common architecture uses both:

                    +---------------------+
                    | Azure App Config     |
                    |                     |
                    | Feature flags       |
                    | Application config  |
                    +----------+----------+
                               |
                               |
Application <------------------+
     |
     |
     +------------------------+
                              |
                              v
                    +---------------------+
                    | Azure Key Vault     |
                    |                     |
                    | API keys            |
                    | Passwords           |
                    | Secrets             |
                    +---------------------+

Do not confuse centralized configuration with secret management.


19. Container Startup Commands

A container has a default startup command defined by its image.

However, App Service can override the startup behavior for a custom container.

This can be useful when:

  • The container’s default command isn’t appropriate.
  • The application requires a specific startup command.
  • Different hosting environments require different startup behavior.

For example:

python app.py

or:

gunicorn --bind 0.0.0.0:8080 app:app

App Service supports specifying a startup command for custom containers.

Exam clue

If a container image works locally but App Service starts it incorrectly, investigate:

  • Startup command
  • Listening port
  • Environment variables
  • Container logs
  • Image configuration

20. Environment Variables and Container Startup

Environment variables are available to the application when the container starts.

For example:

APP_ENVIRONMENT=Production
PORT=8080
MODEL_NAME=my-model

Your application might use:

import os
environment = os.getenv("APP_ENVIRONMENT")
model = os.getenv("MODEL_NAME")

The values can be changed in App Service without changing the container image.

This is especially valuable when promoting the same image through:

Development
Testing
Staging
Production

Each environment can supply different configuration.


21. App Settings Cause Application Restarts

A frequently tested detail is that changing App Service application settings causes the application to restart.

This matters because configuration changes aren’t necessarily applied to an already-running process without interruption.

Microsoft documents that adding, removing, or modifying app settings causes an App Service app restart.

Therefore, if a scenario says:

An administrator changes an application setting and the application immediately restarts.

That is expected behavior.


22. Container Image Updates

Suppose App Service is configured to run:

myacr.azurecr.io/my-ai-api:latest

A developer builds a new version and pushes it using the same tag.

The registry now contains a newer image associated with latest.

However, simply pushing the new image doesn’t necessarily mean that an already-running container immediately changes.

Restarting the App Service causes it to pull the image again.

This is one reason immutable version tags are often preferable for controlled deployments.

For example:

my-ai-api:v1.0.0
my-ai-api:v1.1.0
my-ai-api:v2.0.0

rather than relying exclusively on:

my-ai-api:latest

23. Using latest vs. Versioned Tags

latest

Advantages:

  • Simple
  • Convenient for development

Disadvantages:

  • Doesn’t clearly identify what is deployed
  • Makes rollback more difficult
  • Can make troubleshooting harder
  • Can introduce unexpected image changes

Versioned tags

For example:

my-ai-api:1.4.2

Advantages:

  • Clear version identification
  • Easier rollback
  • Better deployment traceability
  • Easier troubleshooting

For production workloads, versioned image tags are generally a better operational practice.


24. Container Logs and Troubleshooting

When a container doesn’t start correctly, examine the container logs.

Common problems include:

Wrong port

The application listens on:

5000

but App Service expects:

8080

Application crashes

For example:

ModuleNotFoundError

or:

Connection refused

Incorrect environment variable

The application expects:

DATABASE_URL

but App Service defines:

DB_URL

Secret resolution failure

The Key Vault reference isn’t resolving.

Startup command failure

The command specified by App Service doesn’t exist or fails.


25. Container Startup Timeout

Custom containers sometimes take longer to initialize than expected.

App Service provides the WEBSITES_CONTAINER_START_TIME_LIMIT setting to control how long the platform waits for a container to start.

The documented default is 230 seconds, with a maximum of 1,800 seconds.

This can matter for AI applications that have relatively large startup workloads.

However, increasing the startup timeout should not be the first response to every startup problem.

First determine why startup is slow.

For example:

  • Is the container downloading dependencies at startup?
  • Is the application loading a large model?
  • Is it waiting for an external service?
  • Is the application listening on the wrong port?
  • Is the startup command incorrect?

26. HTTPS and Custom Containers

A custom container doesn’t necessarily need to implement HTTPS itself when hosted through App Service.

App Service can handle HTTPS termination at the platform’s front ends.

Therefore, an application can commonly listen for HTTP inside the container while clients connect to the application through HTTPS.

Conceptually:

Client
|
HTTPS
|
v
App Service
|
HTTP
|
v
Container

This is different from saying that application traffic is universally unprotected in every internal configuration; networking and security architecture still matter.


27. Continuous Deployment for Containers

App Service can integrate with container registries to support automated deployments.

A common flow is:

Developer
|
v
Source Repository
|
v
Build
|
v
Container Image
|
v
Azure Container Registry
|
v
App Service

A registry push can be used to trigger a deployment/restart workflow.

App Service supports continuous deployment scenarios involving container registries, including Azure Container Registry.

For production systems, CI/CD is generally preferable to manually rebuilding and deploying containers.


28. A Recommended AI Application Architecture

A reasonable architecture for an AI application hosted in a container on App Service might look like this:

                         Azure Container Registry
                                  |
                                  | Container Image
                                  v
                         +-------------------+
                         |   Azure App       |
                         |     Service       |
                         +---------+---------+
                                   |
                    +--------------+--------------+
                    |                             |
             Environment Variables          Managed Identity
                    |                             |
                    |                             v
                    |                      Azure Key Vault
                    |                             |
                    |                           Secrets
                    |
                    +--------------------+
                                         |
                                         v
                                  AI Application
                                         |
                  +----------------------+----------------+
                  |                      |                 |
                  v                      v                 v
             Azure AI             Azure Database      Azure Storage

The container image contains the application.

App Service provides environment-specific configuration.

Managed identity provides secure access to Azure resources.

Key Vault stores secrets.

This is a strong pattern to recognize in AI-200 scenario questions.


29. Security Best Practices

For the exam, remember these principles.

Don’t hard-code secrets

Avoid:

API_KEY=abc123

inside source code or Dockerfiles.

Don’t put secrets in image layers

Building a secret into an image doesn’t make it secure simply because the image is stored in a private registry.

Use managed identities

When Azure services support Microsoft Entra authentication and managed identities, prefer them over long-lived credentials.

Use Key Vault for secrets

Store sensitive values centrally.

Use least privilege

Grant the App Service identity only the permissions it requires.

Separate environments

Development, testing, and production should have appropriately separated configuration and secrets.

Use versioned images

Prefer:

myapp:1.2.3

over relying exclusively on:

myapp:latest

30. Important AI-200 Exam Concepts to Remember

The following relationships are particularly important:

ConceptRemember
Custom containerRuns your own container image in App Service
Azure Container RegistryCommon private registry for App Service container images
App settingsBecome environment variables
WEBSITES_PORTIdentifies the port used by a custom container
Startup commandControls/overrides how the container application starts
Key VaultSecure centralized secret management
Key Vault referenceAllows an App Service setting to reference a Key Vault secret
Managed identityAvoids storing credentials for Azure resource access
System-assigned identityLifecycle tied to the Azure resource
User-assigned identitySeparate reusable identity resource
App setting changesCause an application restart
Image updateRestart causes App Service to pull the updated image
latestConvenient but less predictable
Versioned tagsBetter traceability and rollback
Container logsImportant for startup/runtime troubleshooting
WEBSITES_CONTAINER_START_TIME_LIMITControls custom-container startup wait time

Practice Exam Questions

Question 1

You have a Python-based AI API packaged as a Linux container. The application listens on port 8080 inside the container.

You deploy the container to Azure App Service, but requests to the application fail because App Service cannot connect to the application.

Which App Service setting should you verify first?

A. WEBSITE_RESOURCE_GROUP

B. WEBSITE_SITE_NAME

C. WEBSITES_PORT

D. WEBSITE_SKU

Answer: C

Explanation

For custom containers, App Service needs to know which port the container is listening on. If the application listens on port 8080, configuring:

WEBSITES_PORT=8080

helps App Service route traffic to the correct container port.

The other settings describe the App Service environment but do not determine the container’s application port.


Question 2

An AI application is deployed as a container to Azure App Service. The application requires an API key that changes periodically.

The development team wants to avoid storing the API key in source code, the Dockerfile, or the container image.

Which solution provides the best approach?

A. Store the API key in the Dockerfile as an ENV value.

B. Store the API key in Azure Key Vault and reference it from an App Service application setting.

C. Store the API key in the container image and use a private Azure Container Registry.

D. Store the API key in the application’s source code and protect the repository with RBAC.

Answer: B

Explanation

Azure Key Vault is designed for centralized secret management. App Service can use a Key Vault reference as an application setting, allowing the application to consume the secret as an environment variable without embedding the secret in the image or source code.

A private container registry protects access to the image but does not make secrets embedded inside the image a good security practice.


Question 3

An Azure App Service application uses a Key Vault reference to retrieve an API key. The application is receiving the literal Key Vault reference string rather than the expected secret value.

Which issue should you investigate?

A. Whether the Dockerfile contains an EXPOSE instruction

B. Whether WEBSITES_PORT matches the application port

C. Whether the App Service managed identity has permission to read the Key Vault secret

D. Whether the image uses the latest tag

Answer: C

Explanation

A Key Vault reference must be resolved by App Service. The application’s managed identity needs permission to retrieve the referenced secret.

A missing or incorrectly configured identity, missing Key Vault permissions, an invalid secret name, or other Key Vault configuration problems can prevent resolution.

The port and image tag are unrelated to Key Vault reference resolution.


Question 4

A development team wants to deploy the same container image to development, test, and production environments. The AI endpoint differs between environments.

What is the best approach?

A. Build a separate Docker image for each environment.

B. Store all three endpoints in the Dockerfile and select one at runtime.

C. Create separate source-code branches containing different endpoint values.

D. Store the endpoint as an App Service application setting in each environment.

Answer: D

Explanation

Environment-specific configuration should be separated from the application image.

Each App Service environment can provide its own application setting:

AI_ENDPOINT=https://development...

or:

AI_ENDPOINT=https://production...

The same container image can therefore be deployed across environments.


Question 5

A developer pushes a new version of an image to Azure Container Registry using the same latest tag that an App Service application is already configured to use.

When should the developer expect App Service to retrieve the updated image?

A. When the running container is restarted

B. Immediately when the image is pushed

C. Only when the App Service plan is resized

D. Only after the image tag is deleted

Answer: A

Explanation

App Service pulls the configured container image when the application starts. If an updated image is pushed using the same tag, restarting the App Service causes the updated image to be pulled.

This is one reason explicit version tags are often preferable for controlled production deployments.


Question 6

An organization wants an App Service application to retrieve secrets from Azure Key Vault without storing a Key Vault password or service principal secret in the application.

Which feature should be used?

A. Docker ENV instructions

B. Managed identity

C. App Service startup command

D. Container port mapping

Answer: B

Explanation

Managed identity allows Azure resources such as App Service to authenticate to supported Azure services without requiring developers to store credentials in application configuration.

For Key Vault references, App Service can use its system-assigned managed identity by default or a configured user-assigned identity.


Question 7

An AI container deployed to App Service takes approximately five minutes to initialize because it performs a large initialization operation before listening for HTTP traffic.

The platform terminates the container before initialization completes.

Which setting can be used to increase the amount of time App Service waits for the container to start?

A. WEBSITES_PORT

B. WEBSITE_SITE_NAME

C. WEBSITES_CONTAINER_START_TIME_LIMIT

D. WEBSITE_WARMUP_PATH

Answer: C

Explanation

WEBSITES_CONTAINER_START_TIME_LIMIT controls how long App Service waits for a custom container to start.

The documented default is 230 seconds and the maximum is 1,800 seconds.

However, increasing the timeout should be done only after determining that the startup delay is legitimate rather than caused by a configuration or application problem.


Question 8

An application administrator changes the value of an App Service application setting.

What should the administrator expect?

A. The setting changes only the next time a new container image is deployed.

B. The setting changes the Dockerfile stored in Azure Container Registry.

C. App Service restarts the application so that the new setting can be supplied to the application environment.

D. The setting automatically modifies the source code in the application repository.

Answer: C

Explanation

App Service application settings are supplied to the application as environment variables. Changes to application settings cause the application to restart, allowing the new configuration to be supplied to the running application.

The setting does not modify the container image, Dockerfile, or source repository.


Question 9

You are designing a production AI application running in a custom container on Azure App Service. The application requires an API key.

Which design provides the strongest separation between application code and the secret?

A. Store the secret in Azure Key Vault and expose it to the application through an App Service Key Vault reference.

B. Store the secret in the Dockerfile using an ENV instruction.

C. Store the secret in a text file inside the container image.

D. Store the secret in the application’s source code and restrict repository access.

Answer: A

Explanation

A Key Vault reference allows the secret to remain in Azure Key Vault while the application consumes it through an App Service configuration setting.

This provides better separation between:

  • Application code
  • Container image
  • Deployment configuration
  • Secrets

The App Service managed identity can be granted the minimum required permissions to retrieve the secret.


Question 10

An organization has multiple App Service applications that need to use the same identity when accessing Azure Key Vault. The identity must also be able to exist independently of the lifecycle of any individual App Service application.

Which type of managed identity should be used?

A. System-assigned managed identity

B. App Service publishing credentials

C. User-assigned managed identity

D. Container registry administrator credentials

Answer: C

Explanation

A user-assigned managed identity is a standalone Azure resource that can be assigned to multiple Azure resources.

This makes it appropriate when:

  • Multiple applications need the same identity.
  • The identity needs an independent lifecycle.
  • The identity must exist before an application is created.
  • The organization wants to reuse the identity across resources.

A system-assigned identity is tied to the lifecycle of its associated Azure resource.


Final Exam Takeaways

For AI-200, the most important mental model is:

The container image contains the application; App Service supplies the environment-specific configuration; Key Vault protects sensitive values; managed identity provides secure access to Azure resources.

When you encounter an exam scenario, think through the problem in this order:

  1. Where is the container image?
    • Azure Container Registry?
    • Another private registry?
    • Public registry?
  2. Can App Service pull the image?
    • Is authentication configured?
    • Would managed identity be appropriate?
  3. What port does the application actually listen on?
    • Does it match the App Service configuration?
    • Is WEBSITES_PORT configured appropriately?
  4. How does the application receive configuration?
    • App Service application settings
    • Environment variables
  5. Does the configuration contain a secret?
    • Use Azure Key Vault rather than embedding the secret in the image or source code.
  6. How does App Service access Key Vault?
    • Managed identity
    • Appropriate Key Vault permissions
  7. Is the container starting correctly?
    • Startup command
    • Container logs
    • Port
    • Environment variables
    • Startup timeout
  8. How is the image version managed?
    • Prefer identifiable/versioned image tags for production deployments.
    • Understand what happens when an image behind a tag is replaced.

These distinctions—particularly App Service settings vs. container image contents, environment variables vs. secrets, Key Vault references vs. hard-coded credentials, and system-assigned vs. user-assigned managed identities—are exactly the kinds of distinctions that can turn a plausible answer into the correct AI-200 answer.


Go to the AI-200 Exam Prep Hub main page

Build and Run Images by Using Azure Container Registry Tasks (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container application hosting
      --> Build and Run Images by Using Azure Container Registry Tasks


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Azure Container Registry Tasks (ACR Tasks) provides cloud-based capabilities for building, testing, and managing container images in Azure Container Registry (ACR).

ACR Tasks is particularly useful when developers want to move container image builds into the cloud rather than relying on a locally installed Docker engine. It can support simple on-demand builds, automated builds triggered by source-code or base-image changes, and more sophisticated multi-step workflows involving multiple containers.

For the AI-200: Developing AI Cloud Solutions on Azure exam, you should understand not only how to execute an ACR Task, but also when to use each type of task, how build contexts work, how images are tagged, how multi-step tasks are defined, how tasks are triggered, and how tasks can securely access other resources.

Microsoft’s AI-200 training specifically identifies building and managing container images in the cloud with ACR Tasks and using the Azure CLI to run ACR quick tasks as learning objectives.


1. What Are Azure Container Registry Tasks?

ACR Tasks is a collection of capabilities within Azure Container Registry that allows you to perform container image operations in Azure.

At a high level:

Source Code / Dockerfile
|
v
ACR Task
|
+-----+-----+
| |
v v
Build Test
| |
+-----+-----+
|
v
Container Image
|
v
ACR

ACR Tasks can:

  • Build container images in Azure
  • Push images to ACR
  • Run containers as part of a task
  • Test container images
  • Build multiple images
  • Execute steps sequentially or in parallel
  • Automatically trigger builds from source-code changes
  • Automatically rebuild images when base images change
  • Run tasks on a schedule
  • Integrate into CI/CD workflows

ACR Tasks supports Linux, Windows, and ARM image platforms, depending on the configuration and supported scenarios.


2. Why Use ACR Tasks?

A traditional container development workflow might look like this:

Developer Computer
|
+-- Docker build
|
+-- Docker test
|
+-- Docker push
|
v
Azure Container Registry

This requires the developer’s machine to have the appropriate container tooling.

With an ACR Task:

Developer
|
| Azure CLI
v
Azure Container Registry
|
+-- Build
+-- Test
+-- Push

The build is performed in Azure.

This has several advantages:

  • No local Docker Engine is required for an ACR quick task.
  • Builds can be standardized.
  • Builds can be automated.
  • Container images can be built close to the registry.
  • Build workflows can be triggered by source-code changes.
  • Base-image updates can automatically initiate rebuilds.
  • More complex build/test workflows can be defined using YAML.

Microsoft describes quick tasks as an integrated development experience that offloads container image builds to Azure and can perform the equivalent of docker build and docker push in the cloud.


3. Three Important ACR Task Scenarios

For AI-200, understand these three categories:

Task typePrimary purpose
Quick taskOn-demand build and push
Automatically triggered taskAutomatically execute when an event occurs
Multi-step taskBuild, test, run, and push multiple images/workflows

These aren’t mutually exclusive concepts.

For example, a multi-step task can also be automatically triggered by a Git commit.


4. Quick Tasks

A quick task is an on-demand container image build performed in Azure.

It is particularly useful during development.

The Azure CLI command is:

az acr build

For example:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

The final . represents the build context.

Conceptually, this performs:

Dockerfile + build context
|
v
ACR Task
|
v
Build image
|
v
Push image
|
v
ACR

The important point is that the build takes place in Azure rather than requiring a local Docker engine.

ACR Tasks’ quick-build capability is essentially a cloud-based equivalent of performing a Docker build and push operation.


5. Understanding the Build Context

One of the most important concepts when using az acr build is the build context.

Consider:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

The . specifies the current directory as the build context.

The build context contains files that are available to the Docker build process.

For example:

orders-api/
├── Dockerfile
├── requirements.txt
├── app.py
└── src/

Running:

az acr build ... .

makes that directory the build context.

The context can also come from other supported locations, including source repositories.


6. Dockerfile and ACR Tasks

ACR Tasks uses familiar Docker build syntax.

For example:

FROM python:3.12
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "app.py"]

You can then build the image with:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

The Dockerfile defines how the container image is constructed.

ACR Tasks handles the build environment and performs the build in Azure.


7. Specifying a Dockerfile

If the Dockerfile has a different name or location, specify it using --file.

For example:

az acr build \
--registry myregistry \
--image orders-api:v1 \
--file Dockerfile.production \
.

You can also specify a Dockerfile located elsewhere relative to the build context.

The important exam concept is:

The build context and Dockerfile are related but are not necessarily the same thing.

The Dockerfile describes the build instructions.

The build context identifies the files available to the build.


8. ACR Tasks Versus Local Docker Builds

Consider this traditional command:

docker build -t orders-api:v1 .

With ACR Tasks, you can use:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

The conceptual difference is:

Local DockerACR Tasks
Build occurs locallyBuild occurs in Azure
Requires Docker EngineNo local Docker Engine required for quick tasks
Image initially exists locallyImage can be pushed directly to ACR
Developer manages build environmentAzure provides the task execution environment

This distinction is a likely source of scenario-based exam questions.


9. Building Without a Local Docker Engine

Suppose a developer has:

  • Azure CLI
  • Access to an Azure Container Registry
  • A Dockerfile
  • Application source code

but doesn’t have Docker installed.

The developer can still build the image using:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

This is one of the strongest scenarios for recognizing ACR Tasks on the exam.


10. Running an Image with ACR Tasks

ACR Tasks can also run containers as part of a task.

The cmd step is used for this purpose in multi-step tasks.

For example:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .
- cmd: $Registry/orders-api:$ID

The cmd step runs a container using the specified image.

This makes it possible to use ACR Tasks for testing.

For example:

Build image
|
v
Run image
|
v
Execute tests
|
v
Push image

The cmd step supports parameters similar to familiar container-run operations, including environment variables and detached execution.


11. Multi-Step Tasks

A multi-step task allows you to create a more sophisticated container workflow.

Instead of simply:

Build → Push

you can implement:

Build
|
v
Run
|
v
Test
|
v
Push

You can also build multiple images:

             +--> Build API ----+
             |                  |
Source ------+                  +--> Test --> Push
             |                  |
             +--> Build Worker -+

Multi-step tasks are defined in a YAML file.

Microsoft identifies three primary ACR Tasks step types:

  • build
  • push
  • cmd

12. The build Step

The build step builds a container image.

Example:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .

Conceptually, this is similar to:

docker build

but the build is performed within the ACR Tasks environment.

The image name should identify the image that the task builds.


13. The push Step

The push step pushes an image to a container registry.

Example:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .
- push:
- $Registry/orders-api:$ID

The build step creates the image.

The push step publishes it to the registry.

An important exam distinction is that in a multi-step az acr run task, you should not assume that a built image is automatically pushed simply because it was built. The task definition can explicitly use a push step to publish it.


14. The cmd Step

The cmd step executes a container.

For example:

version: v1.1.0
steps:
- cmd: bash:3.0 echo "Hello from ACR Tasks"

It can also execute an image produced by an earlier build:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .
- cmd: $Registry/orders-api:$ID

This is especially useful for testing.

The cmd step can use environment variables and other execution options.


15. Build, Test, and Push

A common ACR Tasks pattern is:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .
- cmd: $Registry/orders-api:$ID
- push:
- $Registry/orders-api:$ID

Conceptually:

             BUILD
               |
               v
          Container Image
               |
               v
              TEST
               |
         Tests successful
               |
               v
              PUSH
               |
               v
              ACR

This pattern can prevent an image from being pushed until validation has occurred.


16. Step Dependencies

ACR Tasks allows steps to have dependencies.

The when property can specify which previous steps must complete before a step executes.

For example:

version: v1.1.0
steps:
- id: build
build: -t $Registry/orders-api:$ID .
- id: test
cmd: $Registry/orders-api:$ID
when: ["build"]
- id: push
push:
- $Registry/orders-api:$ID
when: ["test"]

The sequence is:

build
|
v
test
|
v
push

This allows the task to express workflow dependencies explicitly.


17. Parallel Execution

ACR Tasks can also execute independent steps concurrently.

For example:

version: v1.1.0
steps:
- id: build-api
build: -t $Registry/api:$ID .
when: ["-"]
- id: build-worker
build: -t $Registry/worker:$ID ./worker
when: ["-"]

The special:

when: ["-"]

indicates that the step has no dependency on another step and can begin immediately.

Therefore:

        +--> Build API ---+
        |                 |
START --+                 +--> Continue
        |                 |
        +--> Build Worker-+

This can reduce total task execution time when operations are independent.

Microsoft’s ACR Tasks YAML reference specifically documents when: ["-"] for steps that have no dependency and can execute concurrently.


18. Build Dependencies Versus Sequential Steps

If when isn’t specified, a step is dependent on the previous step in the task definition.

For example:

steps:
- id: build
build: -t $Registry/api:$ID .
- id: test
cmd: $Registry/api:$ID
- id: push
push:
- $Registry/api:$ID

This naturally produces:

build → test → push

If explicit dependencies are needed, use when.


19. Running an ACR Task

The Azure CLI command commonly used to execute a task definition is:

az acr run

For example:

az acr run \
--registry myregistry \
--file acr-task.yaml \
.

You can also use a Git repository as the context.

For example:

az acr run \
--registry myregistry \
--file acr-task.yaml \
https://github.com/example/project.git

The task receives the specified source context and executes the defined workflow.


20. az acr build Versus az acr run

This is an important distinction for AI-200.

az acr build

Designed primarily for a quick cloud-based image build.

Example:

az acr build \
--registry myregistry \
--image orders-api:v1 \
.

Think:

Build an image quickly in Azure.

az acr run

Executes an ACR Tasks workflow.

Example:

az acr run \
--registry myregistry \
--file acr-task.yaml \
.

Think:

Run a defined task workflow.

A multi-step task uses az acr run.


21. ACR Tasks Run Variables

ACR Tasks provides built-in run variables.

These variables can be used to create standardized image names and tags.

One particularly useful variable is:

Run.ID

which can be represented in task YAML using the $ID alias.

For example:

steps:
- build: -t $Registry/orders-api:$ID .

This gives each task run a unique identifier that can be incorporated into the image tag.

ACR Tasks also provides variables associated with:

  • Registry
  • Registry name
  • Run ID
  • Date
  • Operating system
  • Architecture
  • Git commit
  • Git branch
  • Task name


22. Why Use Unique Build Tags?

Suppose every build uses:

orders-api:latest

You lose an easy way to distinguish individual builds.

Instead, you could use:

orders-api:build-123
orders-api:build-124
orders-api:build-125

ACR Tasks’ run ID can help automate this.

For example:

steps:
- build: -t $Registry/orders-api:$ID .
- push:
- $Registry/orders-api:$ID

This produces unique image references for individual runs.

This is especially useful for CI/CD scenarios.


23. Automatically Triggered Tasks

ACR Tasks can automatically execute based on events.

Important trigger scenarios include:

Source-code updates

A task can run when code is committed to a supported Git repository.

For example:

Developer commits code
|
v
Git repository
|
v
ACR Task trigger
|
v
Build image
|
v
Push image

Base-image updates

A task can be triggered when a base image changes.

For example:

FROM python:3.12

If the base image is updated, an ACR Task can rebuild the application image.

This is useful for automatically incorporating updated OS or framework components.

Scheduled execution

ACR Tasks can also support scheduled execution.

For example:

Every night
|
v
ACR Task
|
v
Build/test image

Microsoft documents source-code, base-image, and timer-based triggers as ACR Tasks automation scenarios.


24. Base Image Update Triggers

Base image triggers are especially relevant to security and maintenance.

Suppose:

FROM ubuntu:24.04

A security update causes a newer version of the base image to become available.

Without automation:

Base image updated
|
X
Application image remains unchanged

With an ACR Task:

Base image updated
|
v
ACR Task trigger
|
v
Rebuild application image
|
v
Push updated image

This allows organizations to automatically rebuild images when their dependencies change.

Microsoft describes this scenario as a way to automate OS and framework patching for container images.


25. Source-Code Triggers

ACR Tasks can integrate with source repositories.

For example:

Git commit
|
v
ACR Task
|
+-- Build
+-- Test
+-- Push

This provides a simple cloud-based container CI workflow.

A task can be configured to respond to commits and, depending on the configuration, pull-request activity in supported Git repositories.


26. Multi-Container Workflows

ACR Tasks becomes particularly valuable when an application contains multiple containers.

Suppose you have:

Web API
Worker
Test suite

You could define:

Build API
|
Build Worker
|
Run tests
|
Push API
|
Push Worker

Or independent builds could execute concurrently:

            +--> Build API -----+
            |                   |
START ------+                   +--> Test --> Push
            |                   |
            +--> Build Worker --+

Multi-step tasks are designed specifically for these types of workflows.


27. ACR Tasks and CI/CD

ACR Tasks can be incorporated into a broader CI/CD architecture.

For example:

Developer
|
v
Git Repository
|
v
ACR Task
|
+--> Build
|
+--> Test
|
+--> Push
|
v
Azure Container Registry
|
v
Container Apps / AKS / App Service

ACR Tasks is therefore not merely a command for building images. It can serve as a container lifecycle building block within an automated development process.


28. Accessing Other Registries

An ACR Task may need to access images or artifacts outside the registry where the task runs.

For example:

ACR Task
|
| Pull base image
v
External Registry

or:

ACR Task
|
| Push image
v
Another Registry

ACR Tasks supports authentication mechanisms for accessing protected resources.

Managed identities are particularly useful when an ACR Task needs to access other Azure resources without embedding credentials in the task definition.

Microsoft documents both system-assigned and user-assigned managed identities for ACR Tasks.


29. Managed Identities for ACR Tasks

An ACR Task can have a managed identity.

Two types are available:

System-assigned managed identity

The identity is associated with the specific ACR Task resource.

Its lifecycle is tied to that resource.

User-assigned managed identity

The identity is an independent Azure resource that can be assigned to multiple resources.

This can be useful when the same identity needs to be reused.

The key exam concept is:

Managed identities allow ACR Tasks to access protected Azure resources without embedding credentials in the task definition.


30. ACR Tasks and Azure Key Vault

ACR Tasks can also integrate with Azure Key Vault for scenarios where a task needs access to secrets.

A secure architecture might look like:

                 Azure Key Vault
                       |
                       | Secret
                       v
ACR Task ------ Managed Identity
                       |
                       v
                  Build/Test

This is preferable to hard-coding credentials into Dockerfiles, scripts, or task definitions.


31. Security Considerations

When designing ACR Task workflows:

Avoid putting secrets directly on command lines

Command-line arguments can potentially be captured by diagnostic or logging systems.

Avoid embedding credentials in Dockerfiles

A Dockerfile should not contain permanent passwords, tokens, or keys.

Prefer managed identities

When the target resource supports identity-based authentication, managed identities reduce credential-management overhead.

Use least privilege

Give the task only the permissions it needs.

Be careful with external registry credentials

If a task must access another private registry, configure authentication appropriately rather than placing credentials in source code.

Microsoft specifically warns that information supplied through command lines or URIs can appear in ACR diagnostic tracing, including sensitive values.


32. Task YAML Structure

A basic multi-step task looks like:

version: v1.1.0
steps:
- build: -t $Registry/orders-api:$ID .
- push:
- $Registry/orders-api:$ID

A more sophisticated task could look like:

version: v1.1.0
steps:
- id: build-api
build: -t $Registry/orders-api:$ID .
- id: test-api
cmd: $Registry/orders-api:$ID
when: ["build-api"]
- id: push-api
push:
- $Registry/orders-api:$ID
when: ["test-api"]

The key elements are:

ElementPurpose
versionYAML task format version
stepsDefines task operations
buildBuilds an image
pushPushes an image
cmdRuns a container
idGives a step an identifier
whenDefines dependencies
$RegistryRegistry run-variable alias
$IDRun ID alias

ACR Tasks currently supports YAML as the task-definition format.


33. A Complete Build-Test-Push Example

Consider an API application with:

Dockerfile
src/
tests/

A multi-step task could conceptually perform:

version: v1.1.0
steps:
- id: build
build: -t $Registry/orders-api:$ID .
- id: test
cmd: $Registry/orders-api:$ID
when: ["build"]
- id: push
push:
- $Registry/orders-api:$ID
when: ["test"]

The workflow becomes:

                  +----------------+
                  |     Source     |
                  +-------+--------+
                          |
                          v
                       BUILD
                          |
                          v
                    Container Image
                          |
                          v
                        TEST
                          |
                    Tests pass
                          |
                          v
                        PUSH
                          |
                          v
                         ACR

This is an excellent pattern to recognize in scenario-based questions.


34. az acr build Versus Multi-Step Tasks

A useful exam comparison is:

RequirementAppropriate approach
Build one image nowaz acr build
Build image without local Dockeraz acr build
Build and push a simple imageQuick task
Build and test an imageMulti-step task
Build several imagesMulti-step task
Run a container during a workflowcmd step
Push an image from a multi-step taskpush step
Trigger from Git commitAutomatically triggered ACR Task
Rebuild when base image changesBase-image trigger
Run periodicallyScheduled task

35. Common Exam Traps

Trap 1: Choosing Azure Container Instances

ACR Tasks is about building and managing container image workflows.

Azure Container Instances is primarily about running containers.

If the question says:

“Build a container image in Azure without installing Docker locally.”

Think:

ACR Tasks

not Azure Container Instances.


Trap 2: Confusing ACR with ACR Tasks

ACR is the registry.

ACR Tasks provides cloud-based build and automation capabilities.

Think:

ACR
Store images
ACR Tasks
Build/test/automate images

Trap 3: Assuming az acr run and az acr build are identical

They are not.

az acr build is designed for the quick cloud build scenario.

az acr run executes a task definition or command in the ACR Tasks environment.


Trap 4: Assuming every build automatically pushes an image

For a quick az acr build, the resulting image is pushed to the registry by default.

For an az acr run multi-step task, you should explicitly define a push step when you want to push the built image.

This distinction is explicitly documented in the ACR Tasks YAML reference.


Trap 5: Using cmd when you need to build an image

cmd runs a container.

build builds a container image.

Remember:

build → create image
cmd → run container
push → publish image

Trap 6: Ignoring the build context

The build context determines what files are available to the Docker build.

A Dockerfile alone isn’t necessarily sufficient if it references files from the context.


Trap 7: Putting secrets in the Dockerfile

Never assume that a secret belongs in:

ENV PASSWORD=...

or:

RUN some-command --password ...

Use appropriate Azure identity and secret-management mechanisms instead.


36. AI-200 Exam-Focused Review

Make sure you understand the following:

ACR Tasks

Cloud-based container build and automation capabilities.

Quick task

On-demand image build, commonly using:

az acr build

az acr run

Executes an ACR task workflow or command.

Build context

The files supplied to the container build.

build

Builds a container image.

push

Pushes an image to a registry.

cmd

Runs a container as part of a task.

when

Defines dependencies between task steps.

$Registry

Identifies the registry associated with the task run.

$ID

Identifies the current task run and can be used to generate unique tags.

Multi-step task

Supports complex workflows involving building, testing, running, and pushing containers.

Source trigger

Automatically runs a task when supported source-code changes occur.

Base-image trigger

Automatically rebuilds images when a base image changes.

Scheduled trigger

Runs tasks according to a schedule.

Managed identity

Allows a task to access protected Azure resources without embedding credentials.


37. The Mental Model to Remember

For AI-200, think of ACR Tasks as a cloud-based container build and automation engine attached to Azure Container Registry.

                    SOURCE
                       |
             +---------+---------+
             |                   |
          Dockerfile          Git Repo
             |                   |
             +---------+---------+
                       |
                       v
                  ACR TASK
                       |
          +------------+------------+
          |            |            |
        BUILD         CMD         PUSH
          |            |            |
          |          TEST           |
          |            |            |
          +------------+------------+
                       |
                       v
                  ACR IMAGE
                       |
                       v
             Container Service
        +----------+----------+
        |          |          |
       AKS    Container Apps  App Service

The most important distinction is:

ACR stores the image; ACR Tasks builds, tests, and automates the image lifecycle.


Practice Exam Questions

Question 1

A developer has a Dockerfile and application source code but does not have Docker installed locally. The developer needs to build the image in Azure and store it in an Azure Container Registry.

Which command should the developer use?

A. az container create

B. az acr repository create

C. az acr build

D. az aks create

Answer: C

Explanation: az acr build performs a cloud-based container image build using Azure Container Registry Tasks. The build occurs in Azure, so a local Docker Engine isn’t required for this scenario. The command can build and push the resulting image to ACR.


Question 2

A development team wants to create an automated workflow with the following steps:

  1. Build an API container image.
  2. Run the image.
  3. Execute functional tests.
  4. Push the image only if the tests succeed.

Which ACR Tasks capability should be used?

A. A multi-step task

B. ACR geo-replication

C. An ACR repository

D. An Azure Container Apps revision

Answer: A

Explanation: Multi-step ACR Tasks are designed for workflows that combine multiple container operations. The build, cmd, and push step types can be combined, and dependencies can be defined using the when property. This allows testing to occur before the image is pushed.


Question 3

An ACR Task contains the following YAML:

steps:
- id: build
build: -t $Registry/api:$ID .
- id: test
cmd: $Registry/api:$ID
when: ["build"]
- id: push
push:
- $Registry/api:$ID
when: ["test"]

What is the purpose of when: ["test"] on the final step?

A. It causes the push to run before testing

B. It causes the push to run concurrently with testing

C. It causes the push step to be skipped

D. It makes the push step dependent on successful completion of the test step

Answer: D

Explanation: The when property establishes dependencies between task steps. Here, the push step depends on the step identified as test, so it won’t execute until the test step completes successfully.


Question 4

An organization wants an ACR Task to automatically rebuild application images whenever a new version of a base image becomes available.

Which trigger should be configured?

A. A repository namespace trigger

B. A base-image update trigger

C. A container restart trigger

D. An Azure Monitor alert trigger

Answer: B

Explanation: ACR Tasks supports base-image update triggers. When the configured base image changes, the task can automatically rebuild the application image. This is particularly useful for incorporating updated operating-system and framework components.


Question 5

An ACR Task needs to execute two independent image builds at the same time. Which YAML configuration allows the steps to start without depending on another task step?

A. when: ["-"]

B. when: ["parallel"]

C. when: ["async"]

D. when: ["none"]

Answer: A

Explanation: In ACR Tasks, when: ["-"] indicates that the step has no dependency on another step and can begin immediately. This can allow independent steps to execute concurrently.


Question 6

A developer wants to create a unique container image tag for every ACR Task execution. Which ACR Tasks variable is specifically designed to identify the current task run?

A. $Branch

B. $Registry

C. $ID

D. $Architecture

Answer: C

Explanation: $ID is an ACR Tasks alias for the current run ID. It can be used to create unique image tags, such as:

-t $Registry/api:$ID

This is useful for distinguishing images produced by different task executions.


Question 7

A multi-step ACR Task has the following steps:

steps:
- build: -t $Registry/api:$ID .
- push:
- $Registry/api:$ID

What is the primary purpose of the push step?

A. Run the container

B. Upload the built image to a container registry

C. Compile the Dockerfile

D. Create an Azure Container Apps revision

Answer: B

Explanation: The push step publishes a built or retagged container image to a container registry. The build step creates the image; push publishes it.


Question 8

An organization wants an ACR Task to execute whenever developers commit code to a supported Git repository. Which capability should be configured?

A. A source-code trigger

B. An ACR retention policy

C. An ACR private endpoint

D. A container health probe

Answer: A

Explanation: ACR Tasks supports source-code triggers that can automatically execute builds or multi-step tasks when changes occur in supported Git repositories. This provides a simple mechanism for integrating container builds into a CI workflow.


Question 9

An ACR Task must access a protected Azure resource. The organization doesn’t want credentials embedded in the task definition.

Which approach provides the most appropriate Azure-native solution?

A. Store the credential in the Dockerfile

B. Put the password in the task’s command line

C. Use a managed identity for the ACR Task

D. Make the Azure resource publicly accessible

Answer: C

Explanation: ACR Tasks can use system-assigned or user-assigned managed identities to access protected resources without embedding credentials in task definitions. The identity must be granted the required permissions on the target resource.


Question 10

A developer executes:

az acr build \
--registry myregistry \
--image orders-api:v2 \
.

What does the final . represent?

A. The ACR registry name

B. The image tag

C. The Docker image digest

D. The build context

Answer: D

Explanation: The final . specifies the current directory as the build context. Files in the build context are made available to the Docker build process. The Dockerfile and files referenced during the build generally need to be available through the selected context.


Key Takeaways

For the AI-200 exam, remember these relationships:

ConceptRemember
ACRStores and manages container images
ACR TasksBuilds, runs, tests, and automates container workflows
az acr buildPerforms an on-demand cloud image build
az acr runRuns an ACR Tasks workflow/command
Build contextFiles supplied to the image build
buildCreates a container image
cmdRuns a container
pushPublishes an image to a registry
whenControls task-step dependencies
when: ["-"]Allows an independent step to start immediately
$IDCurrent task run identifier
$RegistryRegistry associated with the task
Multi-step taskBuild/test/run/push workflows
Source triggerRun when source code changes
Base-image triggerRebuild when a base image changes
Scheduled triggerRun according to a schedule
Managed identitySecure access without embedding credentials

The single most useful mental model for this objective is:

                  ACR TASKS
                      |
       +--------------+--------------+
       |              |              |
     BUILD           CMD            PUSH
       |              |              |
   Create image    Run/test       Publish image
       |              |              |
       +--------------+--------------+
                      |
                      v
                     ACR

And when the exam gives you a scenario, ask:

  1. Do I need to build an image in Azure?az acr build / ACR Tasks
  2. Do I need multiple build/test/run operations? → Multi-step ACR Task
  3. Do I need to execute a container?cmd
  4. Do I need to publish an image?push
  5. Do steps have dependencies?when
  6. Do independent steps need to run concurrently?when: ["-"]
  7. Should builds happen automatically after source changes? → Source trigger
  8. Should images rebuild when a base image changes? → Base-image trigger
  9. Does the task need secure access to another Azure resource? → Managed identity
  10. Do I need unique image versions for task runs? → Use $ID in the image tag

These distinctions are especially important because AI-200 scenario questions are likely to test which ACR Tasks capability best fits a particular development or deployment requirement, rather than simply asking you to recall an individual command.


Go to the AI-200 Exam Prep Hub main page

Build, Store, Version, and Manage Container Images by Using Azure Container Registry (AI-200 Exam Prep)

This post is a part of the AI-200: Developing AI Cloud Solutions on Azure  Exam Prep Hub.
This topic falls under these sections:
Develop containerized solutions on Azure (20–25%)
   --> Implement container application hosting
      --> Build, store, version, and manage container images by using Azure Container Registry


Note that there are 10 practice questions (with answers) at the end of each section to help you solidify your knowledge of the material. Also, there are 4 practice tests with 30 questions each available from the hub's main page below the exam topics section.

Overview

Azure Container Registry (ACR) is a managed, private registry service in Azure for storing and managing container images and other OCI-compatible artifacts. It provides a central location from which containerized applications can obtain the images they need to run on services such as Azure App Service, Azure Container Apps, Azure Kubernetes Service (AKS), and Azure Container Instances.

For the AI-200: Developing AI Cloud Solutions on Azure exam, you should understand more than simply how to push an image into ACR. You should be comfortable with the hierarchy of registries, repositories, images, tags, manifests, and layers; image versioning strategies; building images using ACR Tasks; managing and deleting images; and selecting appropriate authentication and registry capabilities.

The current Microsoft Learn study guide specifically identifies this objective as part of Implement container application hosting. It also separately identifies ACR Tasks as an exam objective, so understanding how ACR stores images and how ACR Tasks builds them is particularly important.


1. What Is Azure Container Registry?

Azure Container Registry is a private container registry service hosted in Azure.

A container registry solves a fundamental problem in containerized application development:

Where do applications securely obtain the container images they need to run?

Instead of relying exclusively on a public registry, an organization can maintain its own private registry in Azure.

A typical workflow looks like this:

Developer
|
| Build container image
v
Docker / ACR Tasks
|
| Push
v
Azure Container Registry
|
+------------------+
| |
v v
Azure App Service AKS
| |
v v
Container Apps Container workloads

ACR provides capabilities for:

  • Storing container images
  • Storing OCI artifacts
  • Organizing images into repositories
  • Tagging and versioning images
  • Pushing and pulling images
  • Building images using ACR Tasks
  • Managing image metadata
  • Controlling access
  • Replicating images across regions
  • Integrating with Azure container services

Microsoft describes ACR as a private, managed registry that supports building, storing, and managing images for container deployments.


2. Understand the ACR Hierarchy

One of the most important concepts for AI-200 is understanding how ACR organizes container content.

The hierarchy can be thought of as:

Azure Container Registry
|
+-- Repository
| |
| +-- Image : Tag
| +-- Image : Tag
| +-- Image : Tag
|
+-- Repository
|
+-- Image : Tag
+-- Image : Tag

The important concepts are:

  1. Registry
  2. Repository
  3. Artifact/Image
  4. Tag
  5. Manifest
  6. Layer
  7. Digest

Understanding the distinctions between these concepts is a common source of exam questions.


2.1 Registry

The registry is the overall ACR resource.

For example:

contosoregistry.azurecr.io

The registry provides the endpoint through which clients push and pull container images.

A registry can contain many repositories.


2.2 Repository

A repository is a collection of related container images or artifacts.

For example:

contosoregistry.azurecr.io/customer-api

The repository could contain:

customer-api:v1
customer-api:v2
customer-api:v3

Repositories can also use namespaces:

contosoregistry.azurecr.io/marketing/campaign-api:v2

Namespaces help organize repositories logically, although they aren’t independent Azure resources or hierarchical security boundaries simply because they contain / characters.

Microsoft notes that repository names can include namespaces and are managed independently by the registry.


3. Container Image Tags

A tag provides a human-readable identifier for a particular version or variant of an image.

For example:

customer-api:v1
customer-api:v2
customer-api:2026-08-07
customer-api:production

The complete image reference might be:

contosoregistry.azurecr.io/customer-api:v2

The structure is:

<registry>/<repository>:<tag>

For example:

contosoregistry.azurecr.io/customer-api:v2

where:

ComponentValue
Registrycontosoregistry.azurecr.io
Repositorycustomer-api
Tagv2

Microsoft recommends using appropriate tagging strategies for deployment scenarios and notes that latest is used by default when no tag is specified in Docker commands.


4. Tagging and Versioning Strategies

Image versioning is extremely important for reliable deployments.

Consider:

customer-api:latest

This tag is convenient, but it does not necessarily identify an immutable version.

Suppose today’s latest points to:

Image A

and tomorrow the same tag is updated:

latest → Image B

A deployment configured to use latest may therefore receive a different image without its configuration changing.

For production deployments, a better approach is generally to use unique version identifiers.

Examples:

customer-api:v1.0.0
customer-api:v1.1.0
customer-api:v1.2.0

or:

customer-api:20260807.1
customer-api:20260807.2

or a source-control commit identifier:

customer-api:a81f42c

A useful pattern is:

latest → convenient development/testing reference
v1.4.2 → human-readable release
a81f42c → unique build identifier

Exam Tip

If a question asks how to ensure that a deployment consistently uses a specific image version, be cautious about answers using:

:latest

A unique tag or, even more strongly, an image digest provides better version specificity.


5. Image Digests

Container images are also identified by a digest.

For example:

contosoregistry.azurecr.io/customer-api@sha256:abc123...

A digest identifies the content associated with a manifest.

Compare:

customer-api:v2

with:

customer-api@sha256:abc123...

A tag can be moved to point to another image.

A digest identifies a specific content-addressed version.

Microsoft specifically notes that pulling by digest guarantees the image version being retrieved even if an identically tagged image is subsequently pushed.

Exam Tip

Remember:

Tag = human-friendly version reference

Digest = content-addressed, precise image reference


6. Container Image Layers

Container images consist of one or more layers.

Dockerfiles commonly create multiple layers.

For example:

FROM python:3.12
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY app.py .

The resulting image is composed of layers.

One of the advantages of layers is reuse.

If two images share the same base layers, those layers don’t necessarily have to be independently stored and transferred each time.

This can reduce storage and transfer requirements.


7. Manifests

A container image is associated with a manifest.

The manifest contains information needed to identify the image and its layers.

Conceptually:

Image Manifest
|
+-- Configuration
|
+-- Layer 1
+-- Layer 2
+-- Layer 3

The manifest is also associated with the image’s digest.

This distinction matters when managing images in ACR.

For example, removing a tag doesn’t necessarily mean that all image data is immediately removed.

An untagged manifest and its associated layers may continue to consume storage until they are deleted and no longer referenced.

Microsoft specifically warns that repeatedly pushing modified artifacts with identical tags can create untagged artifacts that continue consuming registry storage.


8. Pushing an Image to ACR

A common workflow is:

Step 1: Build the image

docker build -t customer-api:v1 .

Step 2: Tag the image with the ACR login server

docker tag customer-api:v1 \
contosoregistry.azurecr.io/customer-api:v1

Step 3: Authenticate to ACR

az acr login --name contosoregistry

Step 4: Push the image

docker push \
contosoregistry.azurecr.io/customer-api:v1

The image is now stored in:

contosoregistry.azurecr.io/customer-api

with the tag:

v1

9. Pulling an Image

A client can pull the image by tag:

docker pull \
contosoregistry.azurecr.io/customer-api:v1

Or by digest:

docker pull \
contosoregistry.azurecr.io/customer-api@sha256:<digest>

The second approach provides stronger guarantees regarding exactly which image content is retrieved.


10. Azure Container Registry Tasks

One of the most important ACR features for AI-200 is ACR Tasks.

ACR Tasks allows container images to be built in Azure rather than requiring the developer to perform the build locally.

Microsoft describes ACR Tasks as a suite of capabilities for building, testing, and managing container images.

For example:

az acr build \
--registry contosoregistry \
--image customer-api:v1 \
--file Dockerfile .

The command:

  1. Sends the build context to Azure.
  2. Uses the Dockerfile.
  3. Builds the image in Azure.
  4. Tags the resulting image.
  5. Pushes the resulting image into the registry.

This is particularly useful when a developer doesn’t have Docker installed locally.

Microsoft’s current quickstart explicitly demonstrates building, pushing, and running an image using ACR Tasks without requiring a local Docker installation.


11. ACR Tasks Quick Tasks

A quick task is useful for an on-demand image build.

For example:

az acr build \
--registry contosoregistry \
--image customer-api:v1 \
.

This is useful during the development inner loop.

Instead of:

Developer machine
|
+-- docker build
+-- docker tag
+-- docker push

you can use:

Developer
|
| az acr build
v
Azure
|
+-- Build
+-- Tag
+-- Push
v
ACR

12. Automated ACR Tasks

ACR Tasks can also be configured to automatically execute when certain events occur.

For example:

Git commit
|
v
ACR Task
|
+-- Build image
+-- Test image
+-- Push image

ACR Tasks can also respond to base image updates.

For example, suppose an application uses:

FROM python:3.12

A base-image update can trigger an ACR Task to rebuild the application image.

This is useful for keeping application images current when their base images change.

Microsoft documents ACR Tasks triggers for Git commits and base-image updates.


13. Multi-Step ACR Tasks

ACR Tasks can execute more sophisticated workflows.

For example:

Build application image
|
v
Run application
|
v
Run test container
|
v
Push image

Multi-step tasks are defined using YAML.

A simplified example is:

version: v1.1.0
steps:
- build: -t $Registry/customer-api:$ID .
- push:
- $Registry/customer-api:$ID
- cmd: $Registry/customer-api:$ID

ACR Tasks supports three major step types:

StepPurpose
buildBuild a container image
pushPush an image to a registry
cmdRun a container as a command

Exam Tip

If a question describes a workflow that needs to build, test, and push multiple containers, think:

ACR Tasks multi-step task


14. ACR Tasks and External Registries

ACR Tasks can also interact with other registries.

For example, a task may need to:

ACR
|
+-- Pull base image from another registry
|
+-- Build application
|
+-- Push application image to ACR

Credentials can be configured for tasks when access to another registry is required.

For more secure scenarios, ACR Tasks can use managed identities to access protected Azure resources without embedding credentials directly in task definitions.


15. Authentication to Azure Container Registry

ACR is generally private, so clients need appropriate authentication and authorization to access it.

Common authentication approaches include:

  • Microsoft Entra identities
  • Managed identities
  • Service principals
  • Administrator credentials
  • Repository-scoped access mechanisms
  • Anonymous pull, where explicitly configured and supported

Microsoft’s documentation emphasizes that ACR operations such as push and pull require authentication unless anonymous pull is enabled.


16. Managed Identity and ACR

Managed identities are particularly important in Azure-native applications.

Suppose an AKS cluster needs to pull an image:

AKS
|
| Managed Identity
v
Azure Container Registry
|
v
customer-api:v1

Rather than storing a registry password in application configuration, the Azure resource can use a managed identity and appropriate permissions.

For a non-ABAC-enabled registry, a common pull-only role is:

AcrPull

For push and pull:

AcrPush

For ABAC-enabled registries, Microsoft documents repository-scoped roles such as:

Container Registry Repository Reader
Container Registry Repository Writer

The exact role depends on the registry’s authorization model.

Exam Tip

When the question says:

“An Azure service needs to pull images from ACR without storing credentials.”

Think:

Managed identity + appropriate ACR permissions


17. ACR Pricing Tiers

Azure Container Registry currently provides three pricing tiers:

  • Basic
  • Standard
  • Premium

The tiers provide increasing capacity and capabilities.

CapabilityBasicStandardPremium
Intended useLower-volume scenariosProduction scenariosHigh-volume/advanced scenarios
Included storage10 GiB100 GiB500 GiB
Geo-replicationNoNoYes
Private endpointsNoNoYes
Content trustNoNoYes
Customer-managed keysNoNoYes
Dedicated Tasks agent poolsNoNoYes
Higher throughput/concurrencyLowerMediumHigher

All three tiers provide core registry capabilities, while Premium adds advanced capabilities and higher limits.

Important Exam Distinction

If the requirement is:

“Replicate a registry across multiple Azure regions.”

Think:

Premium ACR

Geo-replication is a Premium feature.


18. Geo-Replication

Geo-replication allows an ACR to replicate its content across multiple Azure regions.

For example:

                 Azure Container Registry
                          |
             +------------+------------+
             |                         |
             v                         v
         East US                  West Europe
        Geo-replica               Geo-replica
             |                         |
             v                         v
          AKS US                  AKS Europe

When an image is pushed to the geo-replicated registry, its content is synchronized to the configured replicas.

The advantage is that applications can access images from regions closer to where they run.

Microsoft describes geo-replication as providing a single registry management experience while synchronizing content across selected regions.

Don’t confuse:

Availability zones and geo-replication.

Availability zones provide resilience across zones within a region.

Geo-replication distributes registry content across different Azure regions.

Current Microsoft documentation states that zone redundancy is enabled by default for ACR registries in supported regions across Basic, Standard, and Premium tiers.


19. Managing Images and Repositories

You can manage repositories and images through:

  • Azure portal
  • Azure CLI
  • REST APIs
  • SDKs
  • Docker/OCI tooling

For example, you can list repositories:

az acr repository list \
--name contosoregistry \
--output table

List tags:

az acr repository show-tags \
--name contosoregistry \
--repository customer-api \
--output table

You can also inspect manifests and image metadata.

The Azure portal exposes repositories and their image tags through the registry’s Repositories interface.


20. Deleting Images

Suppose a repository contains:

customer-api:v1
customer-api:v2
customer-api:v3

You can remove an image tag using Azure CLI.

For example:

az acr repository untag \
--name contosoregistry \
--image customer-api:v1

However, remember an important distinction:

Untagging an image does not necessarily immediately remove the underlying image data.

The manifest may become untagged while its layers continue consuming storage.

Microsoft specifically warns about the accumulation of untagged artifacts when images are repeatedly pushed using the same tags.


21. Retention of Untagged Manifests

ACR supports a retention policy for untagged manifests.

The purpose is to automatically remove untagged manifests after a configured period.

For example:

Image:v1
Image:v2
Image:v3

If v2 is removed:

Image:v2 → untagged manifest

A retention policy can eventually remove the untagged manifest.

The current Microsoft documentation identifies the untagged-manifest retention policy as a Premium feature and currently documents it as a preview feature. The policy can be configured for a retention period from 0 through 365 days.

Important Warning

If an application relies on pulling an image by its digest, automatically deleting untagged manifests can make that image unavailable.

This is an important operational consideration and a potential exam scenario.


22. Image Tagging Best Practices

A strong production tagging strategy should make image identification predictable.

A useful approach is to use multiple tags for different purposes.

For example:

customer-api:v2.4.1
customer-api:build-1847
customer-api:a81f42c

You might also maintain:

customer-api:production

as a deployment-oriented alias.

However, don’t rely on a mutable tag such as production or latest when you require immutable deployment behavior.

A good pattern is:

Human-readable release
+
Unique build identifier
+
Optional environment alias

For example:

customer-api:v2.4.1
customer-api:build-1847
customer-api:production

The production deployment can ultimately be pinned to a specific immutable image reference/digest.


23. Common ACR Mistakes

Mistake 1: Using latest for production deployments

latest can change.

Better: use unique version tags and/or digests.


Mistake 2: Assuming deleting a tag deletes the image immediately

An untagged manifest may continue consuming storage.

Better: understand manifests, layers, untagging, deletion, and retention.


Mistake 3: Giving every workload push permissions

An application that only needs to run an image generally doesn’t need permission to push images.

Better: follow least privilege.

For example:

Application → AcrPull
Build pipeline → AcrPush

Mistake 4: Storing registry passwords in application code

This creates unnecessary credential-management risks.

Better: use managed identities or another appropriate identity mechanism.


Mistake 5: Choosing Premium solely because it sounds better

Premium should be selected because its capabilities are required.

Examples include:

  • Geo-replication
  • Private endpoints
  • Content trust
  • Higher throughput
  • Advanced networking
  • Dedicated Tasks agent pools

Mistake 6: Confusing ACR with ACR Tasks

They are related but different concepts.

ACR:

Stores and manages container images.

ACR Tasks:

Builds, tests, and automates container image workflows.

A single ACR resource can therefore be used to store images while ACR Tasks provides the automation to build those images.


24. Important AI-200 Concepts to Know

For this exam objective, make sure you can explain the following without referring to documentation:

ConceptWhat you should know
Azure Container RegistryManaged private container registry
RegistryTop-level ACR resource
RepositoryCollection of related images/artifacts
TagHuman-readable image/version reference
DigestContent-addressed image reference
ManifestDescribes image/artifact and its layers
LayerComponent of a container image
az acr loginAuthenticates a client to ACR
docker pushUploads an image to ACR
docker pullDownloads an image from ACR
az acr buildBuilds an image using ACR Tasks
ACR TasksCloud-based image build/test automation
Multi-step taskBuild/test/push workflows using YAML
AcrPullPull permission for applicable non-ABAC registry scenarios
AcrPushPush/pull permission for applicable non-ABAC registry scenarios
Managed identityCredential-free Azure resource authentication
BasicEntry-level ACR tier
StandardHigher capacity production-oriented tier
PremiumAdvanced capabilities such as geo-replication/private endpoints
Geo-replicationReplicate registry content across regions
Retention policyAutomatically remove eligible untagged manifests

25. AI-200 Scenario Patterns to Recognize

The exam is likely to test your ability to choose the appropriate Azure capability based on a scenario.

Scenario: Build without Docker locally

Requirement: Developers don’t have Docker installed.

Answer: ACR Tasks / az acr build.


Scenario: Automatically rebuild after a Git commit

Requirement: Every source-code commit should trigger an image build.

Answer: ACR Task with a source-code trigger.


Scenario: Rebuild after base image updates

Requirement: Automatically rebuild application images when their base image changes.

Answer: ACR Tasks base-image trigger.


Scenario: Run the same image in several Azure regions

Requirement: Applications in multiple regions should access registry content efficiently.

Answer: ACR Premium with geo-replication.


Scenario: Application only needs to pull images

Requirement: A workload should retrieve images but shouldn’t be able to modify them.

Answer: Grant an appropriate pull-only role, such as AcrPull where applicable, or the appropriate repository reader role for an ABAC-enabled registry.


Scenario: Avoid credentials in application configuration

Requirement: An Azure-hosted application needs to access ACR without storing passwords.

Answer: Managed identity + appropriate registry permissions.


Scenario: Guarantee a specific image

Requirement: A deployment must always retrieve exactly the same image content.

Answer: Use an image digest rather than relying solely on a mutable tag.


26. Quick Review

The following mental model is useful for the exam:

                    AZURE CONTAINER REGISTRY
                             |
             +---------------+---------------+
             |                               |
        Repositories                    ACR Tasks
             |                               |
      +------+------+                  Build/Test/Push
      |             |
   Image          Image
      |             |
    Tags          Tags
      |             |
   Manifest      Manifest
      |
    Layers

And remember the major distinction:

ACR
Store/manage images
ACR Tasks
Build/test/automate images

For production deployments:

Avoid:
:latest
Prefer:
:v2.4.1
:build-1847
@sha256:<digest>

For authentication:

Azure workload
|
| Managed Identity
v
ACR
|
| Appropriate least-privilege role
v
Pull image

For global deployments:

ACR Premium
|
+---- Region 1
|
+---- Region 2
|
+---- Region 3

Practice Exam Questions

Question 1

A development team has a Dockerfile and wants to build a container image directly in Azure. Developers should not need Docker installed on their local computers. The resulting image should be pushed to Azure Container Registry.

Which Azure capability should you use?

A. Azure Container Registry Tasks

B. Azure App Service deployment slots

C. Azure Container Apps revisions

D. Azure Kubernetes Service Jobs

Answer: A

Explanation: Azure Container Registry Tasks can build container images in Azure using a Dockerfile. The az acr build command provides an on-demand build capability and can push the resulting image to ACR. A local Docker installation isn’t required for this workflow.


Question 2

An application image is stored as:

contosoregistry.azurecr.io/orders:v4

What does v4 represent?

A. The registry name

B. The image tag

C. The image digest

D. The repository namespace

Answer: B

Explanation: In an image reference such as:

registry/repository:tag

the portion after the colon is the tag. Therefore, v4 is the image tag. Tags are commonly used to identify image versions.


Question 3

A production application must always retrieve exactly the same container image content. Developers are concerned that a tag could later be reassigned to a different image.

Which image reference should the application use?

A. :latest

B. :production

C. :stable

D. @sha256:<digest>

Answer: D

Explanation: Tags can be moved to different image versions. A digest is a content-addressed identifier and can be used to pull a specific image version. Microsoft specifically identifies digest-based pulls as a way to guarantee the image version being retrieved.


Question 4

An organization deploys applications to Azure regions in North America and Europe. The organization wants container images to be replicated to both regions while maintaining a single ACR management experience.

Which ACR capability should be used?

A. Repository namespaces

B. Availability zones

C. Geo-replication

D. Image tags

Answer: C

Explanation: ACR geo-replication synchronizes registry content across selected Azure regions while allowing the organization to manage the registry as a single logical registry. Geo-replication is a Premium ACR capability.


Question 5

An AKS workload needs to pull private container images from ACR. The organization does not want to store registry passwords in Kubernetes configuration.

Which approach is most appropriate?

A. Use a managed identity with appropriate ACR permissions

B. Store the ACR administrator password in the container image

C. Make the repository publicly accessible

D. Embed an ACR password in the application source code

Answer: A

Explanation: Azure resources can use managed identities to authenticate to ACR without storing credentials in application code or configuration. The identity must be granted the appropriate pull permissions.


Question 6

A development team wants an automated container workflow that performs the following:

  1. Builds an application image.
  2. Runs a test container.
  3. Builds another image.
  4. Pushes the resulting images.

Which ACR capability should the team use?

A. ACR repository namespaces

B. ACR multi-step Tasks

C. ACR geo-replication

D. ACR anonymous pull

Answer: B

Explanation: ACR Tasks supports multi-step workflows using YAML. The workflow can build, run/test, and push one or more images. The available step types include build, push, and cmd.


Question 7

An organization repeatedly pushes new builds using the same image tag. After several months, the registry contains significant amounts of storage that cannot be explained by the currently tagged images.

What is the most likely explanation?

A. ACR automatically creates a new repository for every push

B. Geo-replication is duplicating every image within the same region

C. Previous manifests became untagged while their image data remained in the registry

D. ACR stores every Dockerfile indefinitely

Answer: C

Explanation: Repeatedly pushing modified images using the same tag can result in previous manifests becoming untagged. Their layers can continue consuming registry storage until the underlying content is deleted.


Question 8

A company needs to automatically rebuild its application container whenever a new version of the application’s base container image becomes available.

Which capability should be configured?

A. Azure App Service deployment slots

B. ACR geo-replication

C. ACR repository tagging

D. An ACR Task with a base-image update trigger

Answer: D

Explanation: ACR Tasks can automatically trigger builds when a base image is updated. This is useful for rebuilding application images when their underlying base images change.


Question 9

An organization requires private connectivity to its Azure Container Registry through Azure Private Link. Which ACR pricing tier supports this capability?

A. Premium

B. Basic

C. Standard

D. All three tiers

Answer: A

Explanation: Azure Container Registry Premium supports private endpoints through Private Link. Basic and Standard do not provide this capability according to the current ACR SKU documentation.


Question 10

An administrator removes the v1 tag from an image in an ACR repository. The administrator assumes that the underlying image data has immediately been removed from the registry.

Which statement is correct?

A. Removing a tag always immediately deletes every associated layer

B. Removing a tag converts the image automatically into a public image

C. Removing a tag deletes the entire repository

D. The manifest can become untagged while its data continues consuming storage

Answer: D

Explanation: Removing a tag can leave the manifest untagged while its associated data remains in the registry. Untagged artifacts can continue consuming storage until they are deleted. ACR provides mechanisms such as retention policies for eligible untagged manifests.


Final AI-200 Takeaways

For this particular AI-200 objective, concentrate on these distinctions:

Azure Container Registry

Store and manage container images and artifacts.

ACR repository

Organizes related images.

Tag

Human-readable version/reference that can be reassigned.

Digest

Content-addressed identifier for a specific image version.

Manifest

Describes the image/artifact and its layers.

ACR Tasks

Build, test, and automate container image workflows.

az acr build

Perform an on-demand cloud-based container build.

Multi-step ACR Task

Build/test/push multiple images or perform multi-stage workflows.

Managed identity

Authenticate Azure workloads to ACR without managing passwords.

AcrPull

Pull permission for applicable non-ABAC registry scenarios.

AcrPush

Push/pull permission for applicable non-ABAC registry scenarios.

Premium

Required for capabilities such as geo-replication and private endpoints.

Geo-replication

Replicate registry content across Azure regions.

Retention

Help clean up eligible untagged manifests.

The most important exam mindset is to distinguish where the image is stored, how it is identified, how it is built, and how the workload is authorized to retrieve it. Those four dimensions—registry/repository, tag/digest, ACR Tasks, and authentication/RBAC—cover a large portion of the practical knowledge behind this objective.


Go to the AI-200 Exam Prep Hub main page