Skip to content

Commit 54f0fc3

Browse files
updates based on Product Team feedback
1 parent 9f06afe commit 54f0fc3

1 file changed

Lines changed: 35 additions & 210 deletions

File tree

articles/container-apps/functions-cli.md

Lines changed: 35 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -5,188 +5,38 @@ services: container-apps
55
author: craigshoemaker
66
ms.service: azure-container-apps
77
ms.topic: how-to
8-
ms.date: 11/20/2025
8+
ms.date: 11/25/2025
99
ms.author: cshoe
1010
---
1111

1212
# Manage Azure Functions on Container Apps using Azure CLI
1313

14-
This article shows you how to deploy and manage Azure Functions on Azure Container Apps by using the Azure CLI. You learn how to set up your environment, create the necessary Azure resources and deploy function apps for managing function operations.
14+
This article shows you how to deploy and manage Azure Functions on Azure Container Apps by using the Azure CLI. You learn how to set up your environment, create the necessary Azure resources, and deploy function apps for managing function operations.
1515

1616
## Prerequisites
1717

1818
Before you begin, ensure you have:
1919

2020
- An Azure subscription. If you don't have one, [create a free account](https://azure.microsoft.com/free/).
21-
- [Azure CLI](/cli/azure/install-azure-cli) version 2.0.79 or later.
22-
- A function app ready for containerized deployment.
23-
24-
## Set up your environment
25-
26-
Update your Azure CLI and install the required extensions:
27-
28-
1. Install the required extensions:
29-
30-
```azurecli
31-
# Upgrade the Azure CLI to the latest version
32-
az upgrade
33-
34-
# Register the Microsoft.App resource provider
35-
az provider register --namespace Microsoft.App
36-
37-
# Install the latest version of the Azure Container Apps CLI extension
38-
az extension add --name containerapp --allow-preview true --upgrade
39-
40-
# Sign in to Azure
41-
az login
42-
```
43-
44-
1. Set environment variables for the resources you create.
45-
46-
You can use the given values for these variables, or provide your own.
47-
48-
```bash
49-
RESOURCE_GROUP="myResourceGroup"
50-
LOCATION="eastus"
51-
CONTAINERAPPS_ENVIRONMENT="myContainerAppsEnv"
52-
STORAGE_ACCOUNT_NAME="mystorageaccount$(date +%s)"
53-
STORAGE_ACCOUNT_SKU="Standard_LRS"
54-
APPLICATION_INSIGHTS_NAME="myAppInsights"
55-
CONTAINERAPP_NAME="myFunctionApp"
56-
```
57-
58-
## Create Azure resources
59-
60-
Set up the basic Azure resources needed to run your function app in a container. You create a resource group, set up a Container Apps environment, and add services for storage and monitoring.
61-
62-
1. Create a resource group to contain all your resources.
63-
64-
```azurecli
65-
az group create \
66-
--name $RESOURCE_GROUP \
67-
--location $LOCATION
68-
```
69-
70-
1. Create Container Apps environment. Create a Container Apps environment with workload profiles enabled.
71-
72-
```azurecli
73-
az containerapp env create \
74-
--name $CONTAINERAPPS_ENVIRONMENT \
75-
--resource-group $RESOURCE_GROUP \
76-
--location $LOCATION \
77-
--enable-workload-profiles
78-
```
79-
80-
1. Add workload profiles (optional). For dedicated compute resources, add a workload profile.
81-
82-
```azurecli
83-
# List available workload profiles
84-
az containerapp env workload-profile list-supported -l $LOCATION --output table
85-
86-
# Set workload profile variables
87-
WORKLOAD_PROFILE_NAME="myWorkloadProfile"
88-
WORKLOAD_PROFILE_TYPE="D4"
89-
90-
# Add workload profile
91-
az containerapp env workload-profile add \
92-
--resource-group $RESOURCE_GROUP \
93-
--name $CONTAINERAPPS_ENVIRONMENT \
94-
--workload-profile-type $WORKLOAD_PROFILE_TYPE \
95-
--workload-profile-name $WORKLOAD_PROFILE_NAME \
96-
--min-nodes 1 \
97-
--max-nodes 3
98-
```
99-
100-
1. Create a storage account for your function app.
101-
102-
```azurecli
103-
az storage account create \
104-
--name $STORAGE_ACCOUNT_NAME \
105-
--resource-group $RESOURCE_GROUP \
106-
--location $LOCATION \
107-
--sku $STORAGE_ACCOUNT_SKU
108-
```
109-
110-
1. Get the storage account connection string.
111-
112-
```azurecli
113-
STORAGE_ACCOUNT_CONNECTION_STRING=$(az storage account show-connection-string \
114-
--name $STORAGE_ACCOUNT_NAME \
115-
--resource-group $RESOURCE_GROUP \
116-
--query connectionString \
117-
--output tsv)
118-
```
119-
120-
1. Create an Application Insights resource for monitoring.
121-
122-
```azurecli
123-
az monitor app-insights component create \
124-
--app $APPLICATION_INSIGHTS_NAME \
125-
--location $LOCATION \
126-
--resource-group $RESOURCE_GROUP \
127-
--application-type web
128-
```
129-
130-
1. Get the Application Insights connection string.
131-
132-
```azurecli
133-
APPLICATION_INSIGHTS_CONNECTION_STRING=$(az monitor app-insights component show \
134-
--app $APPLICATION_INSIGHTS_NAME \
135-
--resource-group $RESOURCE_GROUP \
136-
--query connectionString \
137-
--output tsv)
138-
```
139-
140-
## Deploy your function app
141-
142-
Create the container app with configuration for your Functions app.
143-
144-
```azurecli
145-
az containerapp create \
146-
--name $CONTAINERAPP_NAME \
147-
--resource-group $RESOURCE_GROUP \
148-
--environment $CONTAINERAPPS_ENVIRONMENT \
149-
--image mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0 \
150-
--target-port 80 \
151-
--ingress external \
152-
--kind functionapp \
153-
--workload-profile-name $WORKLOAD_PROFILE_NAME \
154-
--env-vars AzureWebJobsStorage="$STORAGE_ACCOUNT_CONNECTION_STRING" APPLICATIONINSIGHTS_CONNECTION_STRING="$APPLICATION_INSIGHTS_CONNECTION_STRING"
155-
```
156-
157-
## Manage multiple revisions (optional)
158-
159-
For scenarios that require multiple revisions with traffic splitting, update your container app to create a new revision.
160-
161-
Use the following command to split traffic between revisions.
162-
163-
```azurecli
164-
az containerapp ingress traffic set \
165-
--name $CONTAINERAPP_NAME \
166-
--resource-group $RESOURCE_GROUP \
167-
--revision-weight revision1=50 \
168-
--revision-weight revision2=50
169-
```
21+
- [Azure CLI](/cli/azure/install-azure-cli) version 2.0.70 or later.
22+
- A [Functions app](functions-usage.md) ready for containerized deployment
17023

17124
## Manage functions
17225

17326
You can manage your deployed functions within Azure Container Apps using the Azure CLI. The following commands help you list, inspect, and interact with the functions running in your containerized environment.
17427

28+
> [!NOTE]
29+
> When dealing with multirevision scenarios, add the `--revision <REVISION_NAME>` parameter to your command to target a specific revision.
30+
17531
### List functions
17632

17733
View all functions deployed in your container app:
17834

17935
```azurecli
18036
# List all functions
18137
az containerapp function list \
182-
--resource-group $RESOURCE_GROUP \
183-
--name $CONTAINERAPP_NAME
184-
185-
# For multi-revision scenarios, specify revision
186-
az containerapp function list \
187-
--resource-group $RESOURCE_GROUP \
188-
--name $CONTAINERAPP_NAME \
189-
--revision myRevisionName
38+
--resource-group <RESOURCE_GROUP> \
39+
--name <CONTAINER_APP_NAME>
19040
```
19141

19242
### Show function details
@@ -195,40 +45,22 @@ Get detailed information about a specific function:
19545

19646
```azurecli
19747
az containerapp function show \
198-
--resource-group $RESOURCE_GROUP \
199-
--name $CONTAINERAPP_NAME \
48+
--resource-group <RESOURCE_GROUP> \
49+
--name <CONTAINER_APP_NAME> \
20050
--function-name HttpExample
20151
```
20252

20353
## Monitor function invocations
20454

205-
Monitoring your function app is essential for understanding its performance and diagnosing issues. The following commands show you how to retrieve function URLs, trigger invocations, and view detailed telemetry and invocation summaries using the Azure CLI.
206-
207-
1. Get your container app's fully qualified domain name (FQDN).
208-
209-
```azurecli
210-
FQDN=$(az containerapp show \
211-
--resource-group $RESOURCE_GROUP \
212-
--name $CONTAINERAPP_NAME \
213-
--query properties.configuration.ingress.fqdn \
214-
--output tsv)
215-
216-
echo "Function URL: https://$FQDN/api/HttpExample"
217-
```
218-
219-
1. To produce telemetry data, trigger your function.
220-
221-
```bash
222-
curl -X POST "https://$FQDN/api/HttpExample"
223-
```
55+
Monitoring your function app is essential for understanding its performance and diagnosing issues. The following commands show you how to retrieve function URLs, trigger invocations, and view detailed telemetry and invocation summaries by using the Azure CLI.
22456

22557
1. To view invocation traces, get detailed traces of function invocations.
22658

22759
```azurecli
22860
az containerapp function invocations traces \
229-
--name $CONTAINERAPP_NAME \
230-
--resource-group $RESOURCE_GROUP \
231-
--function-name HttpExample \
61+
--name <CONTAINER_APP_NAME> \
62+
--resource-group <RESOURCE_GROUP> \
63+
--function-name <FUNCTION_APP_NAME> \
23264
--timespan 5h \
23365
--limit 3
23466
```
@@ -237,67 +69,60 @@ Monitoring your function app is essential for understanding its performance and
23769
23870
```azurecli
23971
az containerapp function invocations summary \
240-
--name $CONTAINERAPP_NAME \
241-
--resource-group $RESOURCE_GROUP \
242-
--function-name HttpExample \
72+
--name <CONTAINER_APP_NAME> \
73+
--resource-group <RESOURCE_GROUP> \
74+
--function-name <FUNCTION_APP_NAME> \
24375
--timespan 5h
24476
```
24577
24678
## Manage function keys
24779
248-
Azure Functions uses keys for authentication and authorization. You can manage different types of keys:
80+
Azure Functions uses [keys for authentication and authorization](/azure/azure-functions/function-keys-how-to). You can manage the following different types of keys:
24981
25082
- **Host keys**: Access any function in the app
25183
- **Master keys**: Provide administrative access
25284
- **System keys**: Used by Azure services
25385
- **Function keys**: Access specific functions
25486
87+
The following commands show you how to manage keys for the host. To run the same command for a specific Functions app, add the `--function-name <FUNCTION_APP_NAME>` parameter to your command.
88+
25589
### List keys
25690
25791
Use the following commands to list host-level and function-specific keys for your Azure Functions running in Container Apps.
25892
93+
> [!NOTE]
94+
> Keep a minimum of one replica running for the following keys management commands to work.
95+
25996
```azurecli
260-
# List host keys
26197
az containerapp function keys list \
262-
--resource-group $RESOURCE_GROUP \
263-
--name $CONTAINERAPP_NAME \
98+
--resource-group <RESOURCE_GROUP> \
99+
--name <CONTAINER_APP_NAME> \
264100
--key-type hostKey
265-
266-
# List function keys (requires function name)
267-
az containerapp function keys list \
268-
--resource-group $RESOURCE_GROUP \
269-
--name $CONTAINERAPP_NAME \
270-
--key-type functionKey \
271-
--function-name HttpExample
272101
```
273102

274103
### Show a specific key
275104

276105
Show the value of a specific host-level key for your function app with the following command:
277106

278107
```azurecli
279-
KEY_NAME="default"
280-
281108
az containerapp function keys show \
282-
--resource-group $RESOURCE_GROUP \
283-
--name $CONTAINERAPP_NAME \
284-
--key-type hostKey \
285-
--key-name $KEY_NAME
109+
--resource-group <RESOURCE_GROUP> \
110+
--name <CONTAINER_APP_NAME> \
111+
--key-name <KEY_NAME> \
112+
--key-type hostKey
286113
```
287114

288115
### Set a key
289116

290117
Set a specific host-level key for your function app with the following command:
291118

292119
```azurecli
293-
KEY_VALUE="your-secure-key-value"
294-
295120
az containerapp function keys set \
296-
--resource-group $RESOURCE_GROUP \
297-
--name $CONTAINERAPP_NAME \
298-
--key-type hostKey \
299-
--key-name $KEY_NAME \
300-
--key-value $KEY_VALUE
121+
--resource-group <RESOURCE_GROUP> \
122+
--name <CONTAINER_APP_NAME> \
123+
--key-name <KEY_NAME> \
124+
--key-value <KEY_VALUE> \
125+
--key-type hostKey
301126
```
302127

303128
## Next steps

0 commit comments

Comments
 (0)