105 lines
2.8 KiB
Markdown
105 lines
2.8 KiB
Markdown
|
# Azure Container Apps
|
||
|
|
||
|
This folder contains additional scripts needed for testing the Azure Container Apps scenario.
|
||
|
|
||
|
## Demo steps:
|
||
|
|
||
|
1. Get the HTTP API application details:
|
||
|
|
||
|
```cli
|
||
|
az containerapp show -g "$RESOURCE_GROUP_NAME" -n podcastapi
|
||
|
```
|
||
|
|
||
|
2. Look for the application's address in the `fqdn` field in the `ingress` config section:
|
||
|
|
||
|
```
|
||
|
"configuration": {
|
||
|
"ingress": {
|
||
|
"external": true,
|
||
|
"fqdn": "<FQDN>",
|
||
|
"targetPort": 80,
|
||
|
"transport": "auto"
|
||
|
},
|
||
|
```
|
||
|
3. Browse the HTTP API to confirm It works.
|
||
|
|
||
|
```
|
||
|
https://<FQDN>
|
||
|
````
|
||
|
|
||
|
4. Open a PowerShell terminal and watch Container Apps:
|
||
|
|
||
|
- `podcastingestionca`: Worker service that scale based on queue messages. When the queue is empty the container app should have 1 instances.
|
||
|
|
||
|
```bicep
|
||
|
scale: {
|
||
|
maxReplicas: 5
|
||
|
minReplicas: 1
|
||
|
rules: [
|
||
|
{
|
||
|
name: 'queue-scaling-rule'
|
||
|
azureQueue: {
|
||
|
queueName: 'feed-queue'
|
||
|
queueLength: 20
|
||
|
auth: [
|
||
|
{
|
||
|
secretRef: 'feedqueue'
|
||
|
triggerParameter: 'connection'
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
```
|
||
|
|
||
|
- `podcastapica`: HTTP API that scale based on concurrent HTTP requests. When there are no incoming requests the container app should have 0 instances.
|
||
|
|
||
|
```bicep
|
||
|
scale: {
|
||
|
minReplicas: 0
|
||
|
maxReplicas: 5
|
||
|
rules: [
|
||
|
{
|
||
|
name: 'httpscalingrule'
|
||
|
http: {
|
||
|
metadata: {
|
||
|
concurrentRequests: '20'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
}
|
||
|
```
|
||
|
4.1 Run this commands to watch container apps scaling out.
|
||
|
|
||
|
```ps1
|
||
|
while (1) {
|
||
|
$output = az containerapp revision list -n podcastapica -g dotnetconf2021-netpodcast --query "[?active].{Name:name, CreatedTime:createdTime, Active:active, Replicas:replicas}" -o table --only-show-errors
|
||
|
clear;
|
||
|
echo $output;
|
||
|
sleep 2;
|
||
|
}
|
||
|
```
|
||
|
```ps1
|
||
|
while (1) {
|
||
|
$output = az containerapp revision list -n podcastingestionca -g dotnetconf2021-netpodcast --query "[?active].{Name:name, CreatedTime:createdTime, Active:active, Replicas:replicas}" -o table --only-show-errors
|
||
|
clear;
|
||
|
echo $output;
|
||
|
sleep 2;
|
||
|
}
|
||
|
```
|
||
|
|
||
|
![Initial replicas](./scale-out-demo-0.png)
|
||
|
|
||
|
5. Simulate some load sending POST requests to the HTTP API. You should see new messages appearing in the Azure Storage Queue. (feed-queue).
|
||
|
|
||
|
```ps1
|
||
|
./Simulate-Feed-Requests.ps1 -baseUrl https://<FQDN>/
|
||
|
```
|
||
|
|
||
|
![Queue messages](./scale-out-demo-2.png)
|
||
|
|
||
|
6. Observe how the HTTP API and the worker scale out.
|
||
|
|
||
|
![Scale out replicas](./scale-out-demo-1.png)
|