Courseiva
Develop Azure compute solutionsmediumMultiple ChoiceObjective-mapped

AZ-204 Develop Azure compute solutions Practice Question

You deploy a containerized background job to Azure Container Instances (ACI). The job should automatically restart only if it exits with a non-zero exit code (i.e., crashes). You want to minimize costs. Which restart policy should you configure?

⚠ Common exam trap

It's easy for candidates to confuse the OnFailure policy with the Always policy, thinking that Always is needed for automatic restarts, but they overlook the cost implication and the specific requirement to restart only on failure.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

OnFailure

The OnFailure restart policy is correct because it restarts the container only when it exits with a non-zero exit code, indicating a crash or error. This matches the requirement to automatically restart only on failure while minimizing costs, as it avoids unnecessary restarts on successful completions.

Answer analysis

Option-by-option breakdown

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

  • Always

    Why it's wrong here

    The "Always" restart policy instructs Azure Container Instances to restart the container every time it stops, regardless of its exit code. For a containerized background job, this means it would be re-executed even upon successful completion (exit code 0), leading to redundant processing, potential data duplication, and unnecessary consumption of Azure resources and associated costs. This policy is generally more suitable for long-running services that are expected to run continuously, not for finite background tasks.

  • OnFailure

    Why this is correct

    The "OnFailure" restart policy is specifically designed for task-based or batch jobs that require retries only when they terminate unexpectedly. It instructs Azure Container Instances to restart the container exclusively when its exit code is non-zero, which signifies an error or abnormal termination. This precisely matches the requirement to restart on failure, preventing unnecessary re-execution of successfully completed jobs and optimizing resource utilization and cost efficiency for idempotent background tasks.

  • Never

    Why it's wrong here

    Setting the restart policy to "Never" means that Azure Container Instances will not automatically restart the container under any circumstances once it has stopped. If the containerized background job encounters an error and crashes, or simply completes its task, it will remain in a terminated state. This policy is unsuitable for a job that requires restarting on failure, as it would leave the job uncompleted and unretried after an issue, failing to meet the operational requirement.

  • Retry

    Why it's wrong here

    The term "Retry" is not a recognized or valid restart policy option within Azure Container Instances (ACI). ACI offers specific, predefined policies such as "Always", "OnFailure", and "Never" to manage container lifecycle after termination. Attempting to configure a container group with a non-existent "Retry" policy would result in a deployment error, as it does not conform to the accepted API specifications for ACI restart policies.

About these practice questions

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

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This AZ-204 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-204 exam.