Merge pull request #53 from Azure/module5

Module5
This commit is contained in:
John Poole 2022-04-28 14:24:50 -04:00 коммит произвёл GitHub
Родитель 4d73023649 af04bb6386
Коммит 53df98ed6d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 155 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,72 @@
# Building and Scaling Azure Container Apps
## Azure Container Apps Features
* Fully managed serverless container service for building and deploying modern apps at scale.
* Write code using your preferred programming language or framework, and build microservices with full support for [Distributed Application Runtime (DAPR)](https://dapr.io/)
* Scale dynamically based on HTTP traffic or events powered by [Kubernetes Event-Driven Autoscaling (KEDA)](keda.sh).
## Pre-requisites
* Completion of Module 1
* Completion of Module 2
* Following variables are set (from Moule 2):
* rg_name
* monitor_connection_string
## Setup
* install the Azure Container Apps extension for the CLI
```cli
az extension add --name containerapp
az provider register --namespace Microsoft.App
```
* set the following environment variables
```cli
CONTAINERAPPS_ENVIRONMENT="order"
app_location=eastus2
```
## Create Azure Container Apps Environment
```cli
az containerapp env create \
--name $CONTAINERAPPS_ENVIRONMENT \
--resource-group $rg_name \
--location $app_location
```
## Create a container app
```cli
az deployment group create --resource-group "$rg_name" \
--template-file tools/deploy/module5/order-processor-app.json \
--parameters \
environment_name="$CONTAINERAPPS_ENVIRONMENT" \
queue_connection_string="$monitor_connection_string" \
location="$app_location"
```
## Scaling Container App with Azure Load Testting (ALT)
* In **Module2** ALT was set up to publish messages to ASB queue to scale the demo app.
* For this module, we just need to re-run the same test, and observe scaling of the pod on virtual nodes
* On Azure Load Testing portal page, in `Test` menu, select the test script that was created in Module 2, and click **run**
* At the bottom of Run Review dialog box, click **Run**
## Observing Scaling of Container App
* Wait until test status shows "Executing"
* On Azure Portal, search of **Container Apps**
* On **Container Apps** home page, select **Metrics** from left hand menu
* On the new chart set up, select **CPU Usage Nanocores** under **Metric** dropdown
* Set the time range to **Last 30 minutes**
* on the selected chart, select "Add Filter"
* Under the **Property** dropdown select **Replica**
* Under the **Values**, you will see multiple replicas of **order-processor** listed
* select one or more replicas to see their CPU usage as they consume messages inserted in the **orders** queue by ALT

Просмотреть файл

@ -0,0 +1,83 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"defaultValue": "eastus2",
"type": "String"
},
"environment_name": {
"defaultValue": "order",
"type": "String"
},
"queue_connection_string": {
"defaultValue": "",
"type": "String"
}
},
"variables": {},
"resources": [
{
"name": "order-processor-app",
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-01-01-preview",
"kind": "containerapp",
"location": "[parameters('location')]",
"properties": {
"managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('environment_name'))]",
"configuration": {
"activeRevisionsMode": "single",
"secrets": [
{
"name": "queueconnection",
"value": "[parameters('queue_connection_string')]"
}]
},
"template": {
"containers": [
{
"image": "ghcr.io/kedacore/sample-dotnet-worker-servicebus-queue:latest",
"name": "order-processor",
"env": [
{
"name": "KEDA_SERVICEBUS_AUTH_MODE",
"value": "ConnectionString"
},
{
"name": "KEDA_SERVICEBUS_QUEUE_NAME",
"value": "orders"
},
{
"name": "KEDA_SERVICEBUS_QUEUE_CONNECTIONSTRING",
"secretref": "queueconnection"
}
]
}
],
"scale": {
"minReplicas": 1,
"maxReplicas": 10,
"rules": [
{
"name": "queue-based-autoscaling",
"custom": {
"type": "azureServicebus",
"metadata": {
"queueName": "orders",
"namespace": "adv-autoscaling",
"messageCount": "2"
},
"auth": [
{
"secretRef": "queueconnection",
"triggerParameter": "connection"
}
]
}
}
]
}
}
}
}]
}