AZ-204 Developing Solutions for Microsoft Azure Exam

You can develop, but can you develop for the cloud? Harness your development skills and learn how to create robust solutions for Microsoft Azure, aiming for your Microsoft Certified: Azure Developer Associate certification!

Practice Test

Exam

Run containers by using Azure Container Instances

Deploy and Manage Containers with Azure CLI

Azure Container Instances (ACI) offer a simple way to run containers in Azure without managing any servers. Using the Azure CLI, you can deploy container images and control their settings with environment variables. This approach lets you set up containers quickly and consistently across different environments. You only need a few commands to get started, making it easy for developers to focus on building applications rather than managing infrastructure.

When creating a container instance, you often need to supply specific environment variables to ensure it runs correctly. For example, you must provide:

  • ApiKey: Tracks billing and must match a valid key in your Azure resource.
  • Billing: Specifies the endpoint URI for billing information.
  • Eula: Confirms that you accept the license agreement by setting Eula=accept.
    Underline: All three settings must be valid or the container won’t start.

In addition to the required settings, you must accept Responsible AI terms by setting RAI_Terms=accept. This explicit acceptance ensures your container complies with Azure’s Responsible AI policies. You can combine all variables into one command, for example:

az container create \
  --resource-group MyResourceGroup \
  --name HealthInsightsContainer \
  --image mcr.microsoft.com/azure-ai/health-insights \
  --environment-variables ApiKey=<yourKey> Billing=<yourEndpoint> Eula=accept RAI_Terms=accept

For deeper monitoring, you can add ApplicationInsights support by including the Instrumentation Key with the ApplicationInsights__InstrumentationKey parameter. This lets you track your container’s performance, errors, and availability. After deployment, use CLI commands to check status and view logs:

  • az container show --resource-group MyResourceGroup --name HealthInsightsContainer
  • az container logs --resource-group MyResourceGroup --name HealthInsightsContainer

Managing your container’s lifecycle is straightforward with Azure CLI. Use az container start or az container restart to launch or refresh your container, and az container stop to shut it down. To see all of your instances and their current state, run az container list. When you need more power, adjust CPU and memory settings in your next deployment to scale your solution.

Conclusion

In this section, you learned how to use the Azure CLI to deploy and manage containers with Azure Container Instances. You covered the basics of creating a container, setting required environment variables, and accepting license and Responsible AI terms. You also saw how to enable optional telemetry with Application Insights and monitor your container’s health using CLI commands. Finally, you discovered how to start, stop, and list your container instances, as well as scale them by changing resource allocation. This knowledge helps you run containerized workloads in Azure without worrying about server management.