An Azure Container Group is a collection of containers that are scheduled on the same host machine. These containers share a lifecycle, local network, and storage volumes, so they act as a single logical unit. Deploying multiple containers in one group is useful when you have a main application and supporting sidecar services, because all related containers start and stop together.
When configuring a group, you must define Resource Allocation by specifying the amount of CPU cores and memory each container needs. Azure allows you to set these values based on your application’s requirements, such as 2 CPU cores and 4 GB of memory. It is important to check regional availability, because not all locations support the same maximum resource limits. Properly sizing your containers helps ensure performance while managing costs.
Containers within the same group share a Public IP Address and a single port namespace, allowing them to communicate via localhost. To persist data, you can use Azure File Shares as mounted volumes that provide shared storage across the group. This is especially helpful for applications that need external files loaded at runtime, because the data remains available even if a container restarts.
Every container group requires a Restart Policy to determine how Azure handles containers that stop running. Selecting the right policy prevents unnecessary resource usage and ensures application reliability. Common policies include:
- Always – Restarts the container regardless of why it stopped.
- OnFailure – Only restarts if the container crashes with a non-zero exit code.
- Never – Does not restart the container automatically.
Deploy and Manage Containers with Azure CLI
Azure Container Instances (ACI) provide a quick way to run containers in Azure without managing servers. Using the Azure CLI, you can deploy container images and configure them with environment variables that control billing, security, and telemetry. ACI containers share a common framework for storage, logging, and security settings, making it easier to maintain consistency across deployments. You can use the az container create command along with the --environment-variables parameter to set these values when you start your container.
To successfully start an Azure AI Health Insights container, you must provide three required environment variables:
- ApiKey – Tracks billing information and must match a valid key in your Health Insights resource.
- Billing – Specifies the endpoint URI for your Azure resource.
- Eula – Confirms that you have accepted the license; set
Eula=accept.
All three settings must be valid, or the container will not start. You retrieve ApiKey and Billing values from the Azure portal under the Health Insights resource’s Keys and endpoint. In addition, you must accept Responsible AI terms by setting RAI_Terms=accept. Use a single CLI command like:
az container create \
--resource-group MyResourceGroup \
--name HealthInsightsContainer \
--image mcr.microsoft.com/azure-ai/health-insights \
--environment-variables ApiKey= Billing= Eula=accept RAI_Terms=accept
For optional telemetry, you can add ApplicationInsights support by specifying ApplicationInsights__InstrumentationKey. This key enables deep monitoring of container performance, availability, and errors. After deployment, you can monitor logs and status with az container show and az container logs. Manage the container lifecycle using az container start, az container stop, and az container list to view all your container instances and their states. Scale resources by adjusting CPU and memory parameters in future deployments.
Implement Networking and Environment Configuration
Azure Container Instances (ACI) provide a serverless platform for running containers without managing the underlying infrastructure. When deploying containers, configuring networking and environment settings is crucial for security, scalability, and integration with other Azure services. Key aspects include setting up public and private networking options, custom DNS, virtual network integration, and managing application settings through environment variables and secure secrets.
Public and Private Networking
ACI supports both public and private networking to control access to your containers. Public networking allows containers to be accessible over the internet, which is useful for web applications or APIs. Private networking integrates with Azure Virtual Networks (VNet) to restrict access to within a specific network, enhancing security for internal services. You can configure these options during deployment using the Azure portal, CLI, or ARM templates. For example, when creating a container group, you can specify the network type and assign a public IP address for external access or use a private IP for internal communication within a VNet.
Virtual Network Integration and Custom DNS
Integrating ACI with an Azure VNet enables secure communication between containers and other resources in the network, such as databases or storage accounts. This integration allows containers to use private IP addresses, reducing exposure to the public internet. Additionally, you can configure custom DNS settings to resolve internal domain names, ensuring seamless connectivity within the VNet. This is particularly important for microservices architectures where services need to discover and communicate with each other securely.
Environment Variables and Secure Secrets
Managing application configuration is done through environment variables, which allow you to inject settings like connection strings or API endpoints into the container at runtime. For sensitive information, such as passwords or keys, Azure provides secure secrets management via Azure Key Vault. Instead of hardcoding secrets, you can reference them from Key Vault, ensuring they are stored encrypted and accessed securely. This approach follows the principle of least privilege and reduces the risk of exposure.
Security and Best Practices
To enhance security, use managed identities for authentication to other Azure services, eliminating the need to store credentials in code. Implement network security groups (NSGs) to control traffic flow and private endpoints for secure access to services like Azure Container Registry. Regularly update container images to include security patches and use liveness and readiness probes to ensure containers are healthy and responsive. Monitoring and logging via Azure Monitor help track performance and detect issues proactively.