This repo demonstrates two use cases of Container Apps using Dapr and KEDA.
Recording of the presentation and demo can be viewed below.
The application consists of:
- A client (Python) container app to generate messages.
- A service (Node) container app to consume and persist those messages in a state store
You can confirm that the services are working correctly by viewing data in your Azure Storage account.
-
Open the Azure portal in your browser and navigate to your storage account.
-
Select Containers from the menu on the left side.
-
Select mycontainer.
-
Verify that you can see the file named
order
in the container. -
Select on the file.
-
Select the Edit tab.
-
Select the Refresh button to observe updates.
Data logged via a container app are stored in the ContainerAppConsoleLogs_CL
custom table in the Log Analytics workspace. You can view logs through the Azure portal or from the command line. Wait a few minutes for the analytics to arrive for the first time before you query the logged data.
Use the following command to view logs in bash or PowerShell.
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'nodeapp' and (Log_s contains 'persisted' or Log_s contains 'order') | project ContainerAppName_s, Log_s, TimeGenerated | take 5" \
--out table
Using Azure Container Apps allows you to deploy applications without requiring the exposure of public endpoints. By using Container Apps scale rules, the application can scale up and down based on the Azure Storage queue length. When there are no messages on the queue, the container app scales down to zero.
for i in {1..7}
do
az storage message put \
--content "Hello Queue Reader App" \
--queue-name "myqueue" \
--connection-string $QUEUE_CONNECTION_STRING
done
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.
Run the following command to see logged messages. This command requires the Log analytics extension, so accept the prompt to install extension when requested.
az monitor log-analytics query \
--workspace $LOG_ANALYTICS_WORKSPACE_CLIENT_ID \
--analytics-query "ContainerAppConsoleLogs_CL | where ContainerAppName_s == 'queuereader' and Log_s contains 'Message ID'" \
--out table
This project is licensed under the MIT License.