You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Manage Azure Functions on Container Apps using Azure CLI
13
13
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.
15
15
16
16
## Prerequisites
17
17
18
18
Before you begin, ensure you have:
19
19
20
20
- 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.
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.
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
170
23
171
24
## Manage functions
172
25
173
26
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.
174
27
28
+
> [!NOTE]
29
+
> When dealing with multirevision scenarios, add the `--revision <REVISION_NAME>` parameter to your command to target a specific revision.
30
+
175
31
### List functions
176
32
177
33
View all functions deployed in your container app:
178
34
179
35
```azurecli
180
36
# List all functions
181
37
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>
190
40
```
191
41
192
42
### Show function details
@@ -195,40 +45,22 @@ Get detailed information about a specific function:
195
45
196
46
```azurecli
197
47
az containerapp function show \
198
-
--resource-group $RESOURCE_GROUP \
199
-
--name $CONTAINERAPP_NAME \
48
+
--resource-group <RESOURCE_GROUP> \
49
+
--name <CONTAINER_APP_NAME> \
200
50
--function-name HttpExample
201
51
```
202
52
203
53
## Monitor function invocations
204
54
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).
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.
224
56
225
57
1. To view invocation traces, get detailed traces of function invocations.
226
58
227
59
```azurecli
228
60
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> \
232
64
--timespan 5h \
233
65
--limit 3
234
66
```
@@ -237,67 +69,60 @@ Monitoring your function app is essential for understanding its performance and
237
69
238
70
```azurecli
239
71
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> \
243
75
--timespan 5h
244
76
```
245
77
246
78
## Manage function keys
247
79
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:
249
81
250
82
- **Host keys**: Access any function in the app
251
83
- **Master keys**: Provide administrative access
252
84
- **System keys**: Used by Azure services
253
85
- **Function keys**: Access specific functions
254
86
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
+
255
89
### List keys
256
90
257
91
Use the following commands to list host-level and function-specific keys for your Azure Functions running in Container Apps.
258
92
93
+
> [!NOTE]
94
+
> Keep a minimum of one replica running for the following keys management commands to work.
95
+
259
96
```azurecli
260
-
# List host keys
261
97
az containerapp function keys list \
262
-
--resource-group $RESOURCE_GROUP \
263
-
--name $CONTAINERAPP_NAME \
98
+
--resource-group <RESOURCE_GROUP> \
99
+
--name <CONTAINER_APP_NAME> \
264
100
--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
272
101
```
273
102
274
103
### Show a specific key
275
104
276
105
Show the value of a specific host-level key for your function app with the following command:
277
106
278
107
```azurecli
279
-
KEY_NAME="default"
280
-
281
108
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
286
113
```
287
114
288
115
### Set a key
289
116
290
117
Set a specific host-level key for your function app with the following command:
0 commit comments