AZ-400 Question 175
Select 2Your team maintains a .NET Core application that is traditionally compiled into binaries and stored in an Azure Artifacts feed. You have been asked to containerize this application and push the resulting container images to an Azure Container Registry (ACR). You want to reuse your existing pipeline in Azure DevOps without adding unnecessary complexity. Which two actions should you implement to containerize and deploy the application to ACR with minimal overhead?
- A
Add a Dockerfile that copies the compiled binaries as the final build stage, then use a Docker build and push task in your pipeline to upload the image to ACR.
- B
Use an ARM template to automatically encapsulate the existing binaries into a container image and push the image to ACR.
- C
Write a script to wrap the compiled binaries in a Docker container at runtime on each deployment, bypassing a dedicated Dockerfile.
- D
Enable a multi-stage build inside the Dockerfile to compile your code and produce the final application container image, then push the built image to ACR in the pipeline.
Show answer and explanation
Correct answers: A, D
Explanation
By using a Dockerfile (with or without multi-stage builds), you can reliably build Docker images in Azure DevOps pipelines and push them to Azure Container Registry. Multi-stage Docker builds (Option 4) reduce the final image size by separating the build and runtime stages. Using the Docker build and push task (Option 1) is a Microsoft best practice for automating container image creation and publication. For more information, refer to Microsoft Docs: https://learn.microsoft.com/azure/devops/pipelines/ecosystems/containers.
- A. Correct.
Correct. A Dockerfile that references your pre-compiled binaries (or compiles them if you choose) is a standard approach. A Docker build and push task in Azure DevOps will automate building and pushing the container image to ACR. This approach is simple and does not introduce extra custom scripts.
- B. Incorrect.
Incorrect. Azure Resource Manager (ARM) templates focus on resource configuration in Azure, not on assembling container images. ARM templates can provision container hosting resources (like Azure Container Instances or AKS) but cannot automatically containerize compiled binaries into a Docker image.
- C. Incorrect.
Incorrect. Dynamically wrapping binaries at runtime with no dedicated Dockerfile is not a recommended pattern for production containers. It lacks repeatability and introduces complexity in managing container lifecycle and dependencies.
- D. Correct.
Correct. Multi-stage Docker builds allow you to compile your .NET Core code in one stage and copy the final build outputs to a minimal runtime image in another stage. This approach is clean, maintains consistent environments, and leverages the pipeline� container tasks to push the image directly to ACR.