Question

Difficulty: HardConfigure Azure Container Instances (ACI)

An administrator is configuring a daily database backup utility using Azure Container Instances (ACI). The utility consists of a single container that connects to a database, exports the data, uploads it to an Azure Blob Storage container, and then terminates.

The backup script is designed to return an exit code of 00 on success, and a non-zero exit code if the upload fails due to transient network issues. If the upload fails, the utility must automatically attempt to rerun the backup. To avoid unnecessary costs, the container must not run after a successful backup.

The administrator deploys the container instance using the default configuration settings. However, they notice that the container group continuously restarts and runs the backup script in an infinite loop, even when the upload succeeds.

Which of the following modifications should the administrator make to achieve the desired behavior?

  1. Change the restart policy of the container group to OnFailureAnswer
  2. B
    Change the restart policy of the container group to Never
  3. C
    Configure a container lifecycle hook to stop the container group after the backup script exits
  4. D
    Deploy the container group inside a virtual network and configure a custom route table to terminate the connection

Answer

Change the restart policy of the container group to OnFailure
By default, Azure Container Instances (ACI) deploys container groups with a restart policy of 'Always'. This causes the container to restart indefinitely, regardless of its exit code. Changing the restart policy to 'OnFailure' ensures the container group will automatically restart if the backup script fails (returns a non-zero exit code) and will stop running (terminating the container group) once it completes successfully (returns an exit code of 0).

Step-by-Step Solution

1
Identify the default restart policy of Azure Container Instances.
By default, ACI container groups are deployed with a restart policy of 'Always'.
This explains why the container group enters an infinite loop, running the script repeatedly even after returning an exit code of 0.
2
Analyze the requirements for container execution and termination.
The container must stop on successful completion (exit code 0) but must restart if it fails (non-zero exit code).
This narrows down the required restart policy to one that distinguishes between success and failure exit codes.
3
Determine the correct restart policy to apply.
The 'OnFailure' restart policy restarts containers only when they fail, and transitions the group to a terminated state upon successful completion.
This satisfies both requirements of stopping on success and retrying on failure.

Key Concept

Restart policies control the lifecycle and automatic restart behavior of container groups in Azure Container Instances.
Rate this question