Deploying to Azure Container Apps Using Terraform and Bicep


As organizations increasingly adopt infrastructure as code (IaC) practices, tools like Terraform and Bicep offer robust, declarative ways to consistently provision Azure resources. This guide explores how to deploy Azure Container Apps using Terraform, which is interwoven with Bicep. It compares their approaches while showing practical examples.
π What Are Azure Container Apps?
Azure Container Apps is a serverless container service that allows developers to deploy containerized applications without managing underlying infrastructure. Itβs built for microservices, APIs, background tasks, and event-driven processing and supports features like autoscaling, Dapr, and HTTP ingress out of the box.
π GitHub Reference
You can find a complete Terraform-based deployment in this repository:
π GitHub β JbravoI/Container_App
This repo demonstrates how to deploy an Azure Container App using Terraform and includes the required configuration to create a resource group, managed environment, and the container app itself.
π§° Tool Overview
Terraform: A widely used open-source IaC tool that supports multi-cloud deployments. It uses its language called HCL (HashiCorp Configuration Language).
π Deployment Flow
Whether using Terraform or Bicep, the general deployment flow looks like this:
Define infrastructure code
Provision an Azure Container Apps environment
Deploy the containerized app with proper configuration
Expose via external ingress or internal networking
β Prerequisites
Azure CLI installed
Docker image in a registry (Azure Container Registry or Docker Hub)
Resource group created
Basic familiarity with Terraform or Bicep
π Deploy Steps
terraform init
terraform plan
terraform apply
Terraform will:
Create the resource group
Deploy a Log Analytics
Set up the container app environment
Deploy the container app using your specified Docker image
On the main file, ensure the Image and Name are correct before any deployment
containers = [
{
image = "mcr.microsoft.com/azuredocs/aci-tutorial-sidecar"
name = "sidecar",
A way to deploy multiple container apps to the same environment was done here: π GitHub β JbravoI/Container_App/Add_con_apps
This process involves an iteration of the variable file containing a list of container apps, images, and settings in the format below:
#Container App Variables
variable "container_apps" {
type = list(object({
name = string
image = string
tag = string
containerPort = number
ingress_enabled = bool
min_replicas = number
max_replicas = number
cpu_requests = number
mem_requests = string
})}
π GitHub β JbravoI/Container_App/Add_con_apps
π Conclusion
Azure Container Apps offers a powerful, serverless platform tailored for modern application architectures, including microservices, APIs, event-driven systems, and background workers. Abstracting away the complexities of container orchestration, it allows developers to focus on building and deploying code rather than managing infrastructure.
When combined with Infrastructure as Code tools like Terraform and Bicep, teams gain the ability to automate deployments, maintain consistency across environments, and adopt DevOps best practices. Whether youβre building scalable web services or lightweight event processors, Azure Container Apps provides the flexibility, scalability, and simplicity to run containerized applications at scale with minimal operational overhead.
Here`s a link to my previous article on Deploying To Azure Container Apps using GitHub Actions.
Subscribe to my newsletter
Read articles from Ewuji John directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
