Courseiva
Develop Azure compute solutionsmediumMultiple ChoiceObjective-mapped

Azure Container Instances Restart Policies: Choosing OnFailure or Never for Cost Savings

You are designing a solution that uses Azure Container Instances (ACI) to run a batch processing job. The job is expected to run for up to 2 hours. You need to minimize costs. Which ACI configuration should you use?

Quick Answer

The answer is to configure your Azure Container Instances with a restart policy of 'OnFailure' or 'Never' to minimize costs. This is correct because ACI bills per second of active container runtime, and a restart policy like 'Always' would cause the container to spin up again after the batch job completes, incurring unnecessary compute charges for idle or repeated execution. On the AZ-204 exam, this scenario tests your understanding of how restart policies directly impact cost optimization for finite workloads like batch processing, often appearing as a trap where candidates overlook the billing implications of automatic restarts. A common memory tip is to associate "finite jobs" with "finite policies"—if the job has a clear end, choose OnFailure or Never to stop the meter.

⚠ Common exam trap

Many exam-takers assume 'Always' is safer for reliability, but for batch jobs that complete successfully, 'Always' causes continuous restarts and unbounded costs, while 'OnFailure' or 'Never' align with the cost-minimization goal.

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

Use a container group with a restart policy of 'OnFailure' or 'Never'.

Setting the restart policy to 'OnFailure' or 'Never' ensures that the container does not restart after the batch job completes, avoiding unnecessary compute charges. ACI bills per second of container runtime, so any idle or restarted container time directly increases cost. For a finite batch job, a restart policy that prevents automatic restarts is the most cost-effective choice.

Answer analysis

Option-by-option breakdown

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

  • Use a container group with a restart policy of 'OnFailure' or 'Never'.

    Why this is correct

    The container stops after the job completes, reducing cost.

  • Use GPU-enabled containers for faster processing.

    Why it's wrong here

    GPUs are more expensive and not needed for typical batch jobs.

  • Deploy the container group in a virtual network.

    Why it's wrong here

    Virtual network is not required for the job and adds cost.

  • Use a container group with a restart policy of 'Always'.

    Why it's wrong here

    Always restart keeps the container running, increasing cost.

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

Same concept, more angles

1 more way this is tested on AZ-204

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. 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?

medium
  • A.Set restart policy to Always and use a private container registry
  • B.Set restart policy to OnFailure and use a single container group
  • C.Set restart policy to Never and use a public container registry
  • D.Set restart policy to OnFailure and deploy in a virtual network

Why B: 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.

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.