Running Azure Functions in Container Apps with Terraform

Running Azure Functions in Container Apps with Terraform was released on May 24, 2024, and that allows you to run Azure Functions in Container Apps using Terraform. In this article, I’ll guide you through the steps to set up and deploy Azure Functions in Container Apps with Terraform. Additionally, for those new to Container Apps, I’ve included a brief overview of their benefits.

Terraform script for Azure Function in Container App Environment

As is tradition on my blog, the source code comes first! You can access the full code [here]. On GitHub, I’ve set up a GitHub Action to run weekly, ensuring the build status is always up-to-date. You can check the current build status below:

Azure Functions in Container Apps with Terraform

To run an Azure Function in Container Apps, all you need is the Container App itself! While you won’t be deploying an Azure Function as a traditional resource, rest assured that all triggers will work seamlessly when the Azure Function runs within the Container App. Currently, there isn’t an option to create an Azure Function resource specifically for use in the Container Apps Environment. However, I don’t see this as a major issue—do you? Below, you’ll find the Terraform script for creating the Azure Function:

Azure Functions in Container Apps with Terraform

Why use Azure Container Apps for Azure Function?

One of the main reasons to run Azure Functions in Azure Container Apps (ACA) is cost efficiency. If this is the only workload you’re hosting, you can take advantage of 180,000 vCPU-seconds and 360,000 GiB-seconds per month at no cost! Additionally, you can integrate your environment with an Azure Virtual Network, providing seamless connectivity.

If you’re adding this as another workload to your existing ACA setup, there won’t be any extra hosting costs, and your environment remains consistent.

However, keep in mind that only the triggers listed below can scale from zero. If you plan to use a trigger not included in this list, you’ll need to set min_replicas to at least 1:

  • HTTP
  • Azure Queue Storage
  • Azure Service Bus
  • Azure Event Hubs
  • Kafka
  • Timer

Summary

In this post, I explore how to run Azure Functions in Container Apps using Terraform, a new feature released in May 2024. I’ll guide you through the setup, offer the source code on GitHub, and discuss cost benefits, including free usage limits. Plus, I highlight key triggers and provide a Terraform script to get you started.

I truly hope you found it enjoyable, and if that’s the case, I would be grateful for a Like or a Comment on my LinkedIn profile.

Leave a Reply

Your email address will not be published. Required fields are marked *