Deploying to Azure Container Apps Using Terraform and Bicep

Ewuji JohnEwuji John
3 min read

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:

  1. Define infrastructure code

  2. Provision an Azure Container Apps environment

  3. Deploy the containerized app with proper configuration

  4. 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.

0
Subscribe to my newsletter

Read articles from Ewuji John directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ewuji John
Ewuji John