|
| 1 | +--- |
| 2 | +title: Create an Azure Functions app with auto scaling rules on Azure Container Apps |
| 3 | +description: Learn to create an Azure Functions app pre-configured with auto scaling rules in Azure Container Apps. |
| 4 | +services: container-apps |
| 5 | +author: craigshoemaker |
| 6 | +ms.service: azure-container-apps |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 03/19/2025 |
| 9 | +ms.author: cshoe |
| 10 | +zone_pivot_groups: azure-cli-or-portal |
| 11 | +--- |
| 12 | + |
| 13 | +# Use Azure Functions in Azure Container Apps |
| 14 | + |
| 15 | +you can create your container app pre-configured with auto-scaling rules fine-tuned for Azure Functions. |
| 16 | + |
| 17 | +TODO |
| 18 | + |
| 19 | +## Prerequisites |
| 20 | + |
| 21 | +- An Azure account with an active subscription. |
| 22 | + - If you don't have one, you [can create one for free](https://azure.microsoft.com/free/). |
| 23 | + |
| 24 | +1. Go to the Azure portal and search for **Container Apps** in the search bar. |
| 25 | + |
| 26 | +1. Select **Container Apps**. |
| 27 | + |
| 28 | +1. Select **Create**. |
| 29 | + |
| 30 | +1. Select **Container App** |
| 31 | + |
| 32 | +1. In the *Basics* tab, enter the following values. |
| 33 | + |
| 34 | + Under *Project details*: |
| 35 | + |
| 36 | + | Property | Value | |
| 37 | + |---|---| |
| 38 | + | Subscription | Select your Azure subscription. | |
| 39 | + | Resource group | Select **Create new resource group**, name it **my-aca-functions-group**, and select **OK**. | |
| 40 | + | Container app name | Enter **my-aca-functions-app**. | |
| 41 | + |
| 42 | +1. Next to *Optimize for Azure Functions* check the checkbox. |
| 43 | + |
| 44 | +1. Under *Container Apps environment* enter: |
| 45 | + |
| 46 | + | Property | Value | |
| 47 | + |---|---| |
| 48 | + | Region | Select a region closest to you. | |
| 49 | + | Container Apps environment | Select **Create new environment**. | |
| 50 | + |
| 51 | +1. In the environment setup window, enter: |
| 52 | + |
| 53 | + | Property | Value | |
| 54 | + |---|---| |
| 55 | + | Environment name | Enter **my-aca-functions-environment**. | |
| 56 | + | Zone redundancy | Disabled | |
| 57 | + |
| 58 | +1. Select **Create** to save your values. |
| 59 | + |
| 60 | +1. Select **Next: Container** to switch to the *Container* tab. |
| 61 | + |
| 62 | +1. In the *Container* tab, enter the following values: |
| 63 | + |
| 64 | +1. Next to *Use quickstart image*, leave this box unchecked. |
| 65 | + |
| 66 | +1. Under the *Container details* section, enter the following values. |
| 67 | + |
| 68 | + | Property | value | |
| 69 | + |---|---| |
| 70 | + | Name | This box is pre-filled with your selection in the last section. | |
| 71 | + | Image source | Select **Docker Hub or other registries** | |
| 72 | + | Subscription | Select your subscription | |
| 73 | + | Image type | Select **Public**. | |
| 74 | + | Registry login server | Enter **mcr.microsoft.com** | |
| 75 | + | Image and tag | Enter **azure-functions/dotnet8-quickstart-demo:1.0** | |
| 76 | + |
| 77 | +1. For *Development stack*, select **.NET** |
| 78 | + |
| 79 | +1. Select **Review + Create**. |
| 80 | + |
| 81 | +:::zone-end |
| 82 | + |
| 83 | +:::zone pivot="azure-cli" |
| 84 | + |
| 85 | +## Prerequisites |
| 86 | + |
| 87 | +- An Azure account with an active subscription. |
| 88 | + - If you don't have one, you [can create one for free](https://azure.microsoft.com/free/). |
| 89 | +- Install the [Azure CLI](/cli/azure/install-azure-cli). |
| 90 | + |
| 91 | +## Setup |
| 92 | + |
| 93 | +To sign in to Azure from the CLI, run the following command and follow the prompts to complete the authentication process. |
| 94 | + |
| 95 | +1. Sign in to Azure. |
| 96 | + |
| 97 | + ```azurecli |
| 98 | + az login |
| 99 | + ``` |
| 100 | +
|
| 101 | +1. To ensure you're running the latest version of the CLI, run the upgrade command. |
| 102 | +
|
| 103 | + ```azurecli |
| 104 | + az upgrade |
| 105 | + ``` |
| 106 | +
|
| 107 | +1. Install or update the Azure Container Apps extension for the CLI. |
| 108 | +
|
| 109 | + If you receive errors about missing parameters when you run `az containerapp` commands in Azure CLI or cmdlets from the `Az.App` module in PowerShell, be sure you have the latest version of the Azure Container Apps extension installed. |
| 110 | +
|
| 111 | + ```azurecli |
| 112 | + az extension add --name containerapp --upgrade |
| 113 | + ``` |
| 114 | +
|
| 115 | + Now that the current extension or module is installed, register the `Microsoft.App` and `Microsoft.OperationalInsights` namespaces. |
| 116 | +
|
| 117 | + ```azurecli |
| 118 | + az provider register --namespace Microsoft.App |
| 119 | + ``` |
| 120 | +
|
| 121 | + ```azurecli |
| 122 | + az provider register --namespace Microsoft.OperationalInsights |
| 123 | + ``` |
| 124 | +
|
| 125 | +1. Create environment variables. |
| 126 | +
|
| 127 | + ```bash |
| 128 | + GROUP_NAME="my-aca-functions-group" |
| 129 | + CONTAINER_APP_NAME="my-aca-functions-app" |
| 130 | + ENVIRONMENT_NAME="my-aca-functions-environment" |
| 131 | + LOCATION="westus" |
| 132 | + ``` |
| 133 | +
|
| 134 | +1. Create a resource group. |
| 135 | +
|
| 136 | + ```azurecli |
| 137 | + az group create \ |
| 138 | + --name $GROUP_NAME \ |
| 139 | + --location $LOCATION \ |
| 140 | + --output none |
| 141 | + ``` |
| 142 | +
|
| 143 | +1. Create Functions container app. |
| 144 | +
|
| 145 | + ```azurecli |
| 146 | + az containerapp create \ |
| 147 | + --resource-group $GROUP_NAME \ |
| 148 | + --name $CONTAINER_APP_NAME \ |
| 149 | + --environment $CONNECTED_ENVIRONMENT_ID \ |
| 150 | + --environment-type connected \ |
| 151 | + --image mcr.microsoft.com/k8se/quickstart:latest \ |
| 152 | + --target-port 80 \ |
| 153 | + --ingress external \ |
| 154 | + --kind functions \ |
| 155 | + --query properties.outputs.fqdn |
| 156 | + ``` |
| 157 | +
|
| 158 | +:::zone-end |
| 159 | +
|
| 160 | +## Related content |
| 161 | +
|
| 162 | +- [Create your first containerized functions](/azure/azure-functions/functions-deploy-container-apps) |
0 commit comments