AZ-204 Develop Azure compute solutions Practice Question
You deploy a container to Azure Container Instances (ACI). The container runs a background job that 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
Test-takers frequently confuse OnFailure with Always, thinking that any restart policy that restarts on failure must also restart on success, or they may over-engineer the solution by adding unnecessary features like a virtual network or private registry.
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
✓
Set restart policy to OnFailure and use a single container group
The OnFailure restart policy restarts the container only when it exits with a non-zero exit code, which matches the requirement to restart only on crashes. This policy minimizes costs because the container does not run continuously when it exits successfully, unlike the Always policy. Using a single container group is the simplest and most cost-effective deployment for a single background job.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Set restart policy to Always and use a private container registry
Why it's wrong here
The "Always" restart policy continuously restarts the container, even after a successful exit. This behavior is inefficient and incurs unnecessary costs for tasks designed to complete and exit gracefully, as it would perpetually re-execute or attempt to re-execute a finished job. Using a private container registry, while a common practice for secure deployments, has no direct bearing on the container's restart policy or its operational behavior post-exit.
- ✓
Set restart policy to OnFailure and use a single container group
Why this is correct
The "OnFailure" restart policy is optimal for ensuring application resilience by automatically restarting a container only if it terminates with a non-zero exit code, indicating an error or crash. This prevents manual intervention for transient failures while avoiding unnecessary restarts for successful completions. Deploying within a single container group represents the simplest and most cost-effective architecture in Azure Container Instances, as it minimizes resource overhead and management complexity.
- ✗
Set restart policy to Never and use a public container registry
Why it's wrong here
Setting the restart policy to "Never" means that if the container process terminates for any reason, including a crash or unhandled exception, Azure Container Instances will not attempt to restart it. This approach lacks resilience, as any failure would require manual intervention to redeploy or restart the container, making it unsuitable for applications requiring continuous availability or automatic recovery. The choice of a public container registry, while impacting image access, does not influence the container's restart behavior or its ability to recover from failures.
- ✗
Set restart policy to OnFailure and deploy in a virtual network
Why it's wrong here
While the "OnFailure" restart policy is indeed appropriate for ensuring a container automatically recovers from crashes, deploying the container within a virtual network introduces unnecessary complexity and cost if network isolation or integration with existing VNet resources is not explicitly required. A virtual network primarily provides enhanced security and private networking capabilities, which are distinct concerns from the container's restart behavior and do not directly contribute to its ability to self-recover from failures.
Go deeper
Related to this question
About these practice questions
Courseiva writes every AZ-204 question from scratch — 881 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.