Azure Container Apps hosting of Azure Functions
Azure Functions provides integrated support for developing, deploying, and managing containerized function apps on Azure Container Apps. Use Azure Container Apps to host your function app containers when you need to run your event-driven functions in Azure in the same environment as other microservices, APIs, websites, workflows or any container hosted programs. Container Apps hosting lets you run your functions in a Kubernetes-based environment with built-in support for open-source monitoring, mTLS, Dapr, and KEDA
Support for hosting function apps on Azure Container Apps is currently in preview.
Integration with Container Apps lets you use the existing functions programming model to write function code in your preferred programming language or framework supported by Azure Functions. You still get the Functions triggers and bindings with event-driven scaling. Container Apps uses the power of the underlying Azure Kubernetes Service (AKS) while removing the complexity of having to work with Kubernetes APIs.
This integration also means that you can use existing Functions client tools and the portal to create containers, deploy function app containers to Container Apps, and configure continuous deployment. Network and observability configurations are defined at the Container App environment level and apply to all microservices running in a Container Apps environment, including your function app. You also get the other cloud-native capabilities of Container Apps, including KEDA, Dapr, Envoy. You can still use Application Insights to monitor your functions executions.
Deploying Azure Functions to Container Apps
In the current preview, you must deploy your functions code in a Linux container that you create. Functions maintains a set of language-specific base images that you can use to generate your containerized function apps. When you create a Functions project using Azure Functions Core Tools and include the
--docker option, Core Tools also generates a Dockerfile that you can use to create your container from the correct base image.
Azure Functions currently supports the following methods of deployment to Azure Container Apps:
- Azure CLI
- Azure portal
- GitHub Actions
- Azure Pipeline tasks
- ARM templates
- Bicep templates
- Azure Functions Core Tools
To learn how to create and deploy a function app container to Container Apps using the Azure CLI, see Create your first containerized functions on Azure Container Apps.
When creating your own containers, you are required to keep the base image of your container updated to the latest supported base image. Supported base images for Azure Functions are language-specific and are found in the Azure Functions base image repos.
The Functions team is committed to publishing monthly updates for these base images. Regular updates include the latest minor version updates and security fixes for both the Functions runtime and languages. You should regularly update your container from the latest base image and redeploy the updated version of your container.
When you make changes to your functions code, you must rebuild and republish your container image. For more information, see Update an image in the registry.
Configure scale rules
Azure Functions on Container Apps is designed to configure the scale parameters and rules as per the event target. You don't need to worry about configuring the KEDA scaled objects. You can still set minimum and maximum replica count when creating or modifying your function app. The following Azure CLI command sets the minimum and maximum replica count when creating a new function app in a Container Apps environment from an Azure Container Registry:
az functionapp create --name <APP_NAME> --resource-group <MY_RESOURCE_GROUP> --max-replicas 15 --min-replicas 1 --storage-account <STORAGE_NAME> --environment MyContainerappEnvironment --image <LOGIN_SERVER>/azurefunctionsimage:v1 --registry-username <USERNAME> --registry-password <SECURE_PASSWORD>
The following command sets the same minimum and maximum replica count on an existing function app:
az functionapp config container set --name <APP_NAME> --resource-group <MY_RESOURCE_GROUP> --max-replicas 15 --min-replicas 1
Considerations for Container Apps hosting
Keep in mind the following considerations when deploying your function app containers to Container Apps:
- Container Apps support for Functions is currently in preview and is only available in the following regions:
- Australia East
- Central US
- East US
- East US 2
- North Europe
- South Central US
- UK South
- West Europe
- West US 3
- When your container is hosted in a Consumption + Dedicated plan structure, only the default Consumption plan is currently supported. Dedicated plans in this structure aren't yet supported for Functions. When running functions on Container Apps, you're charged only for the Container Apps usage. For more information, see the Azure Container Apps pricing page.
- While all triggers can be used, only the following triggers can dynamically scale (from zero instances) when running on Container Apps:
- Azure Queue Storage
- Azure Service Bus
- Azure Event Hubs
*The protocol value of
sslisn't supported when hosted on Container Apps. Use a different protocol value.
- For the built-in Container Apps policy definitions, currently only environment-level policies apply to Azure Functions containers.
- When using Container Apps, you don't have direct access to the lower-level Kubernetes APIs.
containerappextension conflicts with the
appservice-kubeextension in Azure CLI. If you have previously published apps to Azure Arc, run
az extension listand make sure that
appservice-kubeisn't installed. If it is, you can remove it by running
az extension remove -n appservice-kube.
- The Functions Dapr extension is also in preview, with help provided in the repository.