AZ-104 Deploy and Manage Azure Compute Practice Question
Exhibit
Container group configuration: - Name: cg-nightly-import - Container image: contoso.azurecr.io/importer:1.2 - Job behavior: the process imports files, exits with code 0 on success, and should not run again until the next scheduled deployment - Requirement: do not restart the container after successful completion
Based on the exhibit, which restart policy should be configured for the container group?
⚠ Common exam trap
Many exam-takers confuse Docker's native restart policies (which include 'UnlessStopped') with Azure Container Instances' supported policies, leading them to select 'UnlessStopped' even though it is not available in ACI.
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
✓
Never
The container group in the exhibit is configured with a restart policy of 'Never' because it is designed to run a batch job that should execute once and then terminate. Azure Container Instances supports three restart policies: Always, OnFailure, and Never. Since the task is a one-time job, 'Never' ensures the container does not restart after completion, which is the correct choice for a single-run workload.
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
Always forces the container runtime to restart the container process regardless of its exit code, even after a clean exit with code 0. For a one-time import job, this creates an infinite loop of repeated executions: every time the batch completes successfully, ACI immediately starts it again, causing duplicate imports and wasted compute. It also prevents the deployed resource from ever reaching a stable 'Completed' state, which is incompatible with a finite batch workload.
When this WOULD be correct
For a container group running a long-lived service like a web server that must be automatically restarted after any crash or stop, 'Always' is correct.
- ✗
OnFailure
Why it's wrong here
OnFailure is tempting because it restarts only when the container exits with a non-zero exit code, which seems to protect against transient errors. However, this policy is still designed for jobs that should retry after failures and then stop — it does not match the exhibit's requirement that the job simply run once and stop, whether it succeeds or fails. The presence of OnFailure would mask the distinction between a completed run and a failed run in monitoring, because both eventually leave the container stopped but the failed one incurs restart delays and potential side effects. It also contradicts the typical pattern for an idempotent, scheduled batch process that should not auto-retry within the same deployment.
When this WOULD be correct
A container group runs a batch processing job that should automatically restart only if it fails (non-zero exit code). For example, a data transformation task that must be retried upon failure until success.
- ✓
Never
Why this is correct
Never is the correct restart policy for a one-time task that should stop after finishing successfully. The exhibit describes a batch-style import job, not a long-running service. Using Never ensures the container exits and stays stopped until the next deployment or scheduled run. That behavior matches operational expectations for a completed import process.
- ✗
UnlessStopped
Why it's wrong here
UnlessStopped is a host-level policy from Docker that means the container restarts unless it was explicitly stopped by a user or the deployment is removed. In Azure Container Instances, this policy is not the default and is generally intended for long-running daemon-style containers, not one-shot tasks. For the batch import job, this policy would keep the container alive or restart it on reboots or platform maintenance events, which defeats the purpose of a finite run and could cause the import logic to execute more than once. It also requires manual intervention to stop the container afterward, breaking the automated expectation that the job completes and exits on its own.
When this WOULD be correct
In a Docker environment (not Azure Container Instances), 'UnlessStopped' is a valid restart policy. An exam question about Docker container restart policies where the container should restart unless explicitly stopped would have 'UnlessStopped' as the correct answer.
Option-by-option analysis
Why each answer is right or wrong
Understanding why wrong answers are wrong — and when they would be correct — is what separates a 750 score from a 900. The AZ-104 exam frequently reuses these exact scenarios with slightly different constraints.
✓NeverCorrect answer▾
Why this is correct
Never is the correct restart policy for a one-time task that should stop after finishing successfully. The exhibit describes a batch-style import job, not a long-running service. Using Never ensures the container exits and stays stopped until the next deployment or scheduled run. That behavior matches operational expectations for a completed import process.
✗AlwaysWrong answer — click to see why▾
Why this is wrong here
The exhibit shows a container group that runs a batch job; 'Always' would cause the container to restart indefinitely even after successful completion, which is not desired for a one-time task.
★ When this WOULD be the correct answer
For a container group running a long-lived service like a web server that must be automatically restarted after any crash or stop, 'Always' is correct.
Why candidates choose this
Candidates may think 'Always' is the default or safest restart policy, not realizing that for batch jobs or tasks that should run once, 'Never' or 'OnFailure' is appropriate.
✗OnFailureWrong answer — click to see why▾
Why this is wrong here
The container group is designed for a single-run task (e.g., a batch job) that must not restart after completion. OnFailure would restart the container if it exits with a non-zero code, but the task is expected to succeed and should not restart even on failure.
★ When this WOULD be the correct answer
A container group runs a batch processing job that should automatically restart only if it fails (non-zero exit code). For example, a data transformation task that must be retried upon failure until success.
Why candidates choose this
Candidates often associate OnFailure with batch jobs that need retry on error, but overlook that the question's exhibit shows a task that must not restart under any condition, making Never the correct choice.
✗UnlessStoppedWrong answer — click to see why▾
Why this is wrong here
The question asks for a restart policy for a container group, and 'UnlessStopped' is not a valid restart policy for Azure Container Instances; the valid options are Always, Never, and OnFailure.
★ When this WOULD be the correct answer
In a Docker environment (not Azure Container Instances), 'UnlessStopped' is a valid restart policy. An exam question about Docker container restart policies where the container should restart unless explicitly stopped would have 'UnlessStopped' as the correct answer.
Why candidates choose this
Candidates may confuse Docker restart policies with Azure Container Instances policies, or they might think 'UnlessStopped' is a more flexible version of 'Always' that stops restarting when the container is manually stopped.
Analysis generated from the official AZ-104blueprint and verified against question context. The “when correct” sections are what AI assistants cite when candidates ask “what’s the difference between these options?”
Go deeper
Related to this question
Learn chapter
Managed Identities for Azure Resources
Key term
Azure Container Instances
Azure Container Instances (ACI) is a PaaS service that lets you run a container directly in Azure without managing any underlying servers or orchestration.
Key term
Group
A group is a collection of users, devices, or other objects that are assigned permissions and policies together for simplified management in identity and governance systems like Microsoft Entra ID.
About these practice questions
Courseiva writes every AZ-104 question from scratch — 1,049 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-104 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-104 exam.