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
Copy file name to clipboardExpand all lines: articles/container-apps/background-processing.md
+93-57Lines changed: 93 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,31 +38,55 @@ az containerapp env create \
38
38
--location "$LOCATION"
39
39
```
40
40
41
-
# [PowerShell](#tab/powershell)
41
+
# [Azure PowerShell](#tab/azure-powershell)
42
42
43
-
```azurecli
44
-
az containerapp env create `
45
-
--name $CONTAINERAPPS_ENVIRONMENT `
46
-
--resource-group $RESOURCE_GROUP `
47
-
--location $LOCATION
43
+
A Log Analytics workspace is required for the Container Apps environment. The following commands create a Log Analytics workspace and save the workspace ID and primary shared key to environment variables.
Choose a name for `STORAGE_ACCOUNT`. Storage account names must be *unique within Azure* and be from 3 to 24 characters in length containing numbers and lowercase letters only.
78
+
Begin by defining a name for the storage account. Storage account names must be *unique within Azure* and be from 3 to 24 characters in length containing numbers and lowercase letters only.
55
79
56
80
# [Bash](#tab/bash)
57
81
58
82
```bash
59
-
STORAGE_ACCOUNT="<storage account name>"
83
+
STORAGE_ACCOUNT_NAME="<STORAGE_ACCOUNT_NAME>"
60
84
```
61
85
62
-
# [PowerShell](#tab/powershell)
86
+
# [Azure PowerShell](#tab/azure-powershell)
63
87
64
-
```powershell
65
-
$STORAGE_ACCOUNT="<storage account name>"
88
+
```azurepowershell
89
+
$StorageAcctName = "<StorageAccountName>"
66
90
```
67
91
68
92
---
@@ -73,22 +97,24 @@ Create an Azure Storage account.
A result of `Microsoft.Azure.Storage.Core.NullType` is returned when the message is added to the queue.
182
+
150
183
---
151
184
152
185
## Deploy the background application
@@ -245,20 +278,22 @@ az deployment group create --resource-group "$RESOURCE_GROUP" \
245
278
location="$LOCATION"
246
279
```
247
280
248
-
# [PowerShell](#tab/powershell)
281
+
# [Azure PowerShell](#tab/azure-powershell)
249
282
250
-
```powershell
251
-
$params = @{
252
-
environment_name = $CONTAINERAPPS_ENVIRONMENT
253
-
location = $LOCATION
254
-
queueconnection=$QUEUE_CONNECTION_STRING
283
+
```azurepowershell
284
+
$Params = @{
285
+
environment_name = $ContainerAppsEnvironment
286
+
location = $Location
287
+
queueconnection = $QueueConnectionString
255
288
}
256
289
257
-
New-AzResourceGroupDeployment `
258
-
-ResourceGroupName $RESOURCE_GROUP `
259
-
-TemplateParameterObject $params `
260
-
-TemplateFile ./queue.json `
261
-
-SkipTemplateParameterPrompt
290
+
$DeploymentArgs = @{
291
+
ResourceGroupName = $ResourceGroupName
292
+
TemplateParameterObject = $Params
293
+
TemplateFile = './queue.json'
294
+
SkipTemplateParameterPrompt = $true
295
+
}
296
+
New-AzResourceGroupDeployment @DeploymentArgs
262
297
```
263
298
264
299
---
@@ -269,7 +304,7 @@ The application scales out to 10 replicas based on the queue length as defined i
269
304
270
305
## Verify the result
271
306
272
-
The container app runs as a background process. As messages arrive from the Azure Storage Queue, the application creates log entries in Log analytics. You must wait a few minutes for the analytics to arrive for the first time before you are able to query the logged data.
307
+
The container app runs as a background process. As messages arrive from the Azure Storage Queue, the application creates log entries in Log analytics. You must wait a few minutes for the analytics to arrive for the first time before you're able to query the logged data.
273
308
274
309
Run the following command to see logged messages. This command requires the Log analytics extension, so accept the prompt to install extension when requested.
275
310
@@ -280,16 +315,14 @@ LOG_ANALYTICS_WORKSPACE_CLIENT_ID=`az containerapp env show --name $CONTAINERAPP
280
315
281
316
az monitor log-analytics query \
282
317
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
283
-
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID'" \
318
+
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID' | project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Log_s | take 5" \
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $LOG_ANALYTICS_WORKSPACE_CLIENT_ID -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID'"
324
+
```azurepowershell
325
+
$queryResults = Invoke-AzOperationalInsightsQuery -WorkspaceId $WorkspaceId -Query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID' | project Time=TimeGenerated, AppName=ContainerAppName_s, Revision=RevisionName_s, Container=ContainerName_s, Message=Log_s | take 5"
293
326
$queryResults.Results
294
327
```
295
328
@@ -300,7 +333,10 @@ $queryResults.Results
300
333
301
334
## Clean up resources
302
335
303
-
Once you are done, run the following command to delete the resource group that contains your Container Apps resources.
336
+
Once you're done, run the following command to delete the resource group that contains your Container Apps resources.
337
+
338
+
>[!CAUTION]
339
+
> The following command deletes the specified resource group and all resources contained within it. If resources outside the scope of this tutorial exist in the specified resource group, they will also be deleted.
This command deletes the entire resource group including the Container Apps instance, storage account, Log Analytics workspace, and any other resources in the resource group.
0 commit comments