dotnet-podcasts/docs/demos/azurecontainerapps/Readme.md

3.2 KiB

Azure Container Apps

This folder contains additional scripts needed for testing the Azure Container Apps scenario.

You must first enable the feeds injestion API by turning it on in the api.deployment.json file on line 64.

"deployIngestion": true

Demo steps:

  1. Get the HTTP API application details:

    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.

    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.

    scale: {
       minReplicas: 0
       maxReplicas: 5
       rules: [
         {
           name: 'httpscalingrule'
           http: {
             metadata: {
               concurrentRequests: '20'
             }
           }
         }
       ]
     }
    

    4.1 Run this commands to watch container apps scaling out.

    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;
    }
    
    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;
    }
    
        while (1) { 
        $output = ./MessageCount.ps1 -storageAccount <storageAccountName> -accessKey <accessKey>
        clear;
        echo $output;
        sleep 1;
    }
    

    Initial replicas

  1. Simulate some load sending POST requests to the HTTP API. You should see new messages appearing in the Azure Storage Queue. (feed-queue).

    ./Simulate-Feed-Requests.ps1 -baseUrl https://<FQDN>/
    

    Queue messages

  2. Observe how the HTTP API and the worker scale out.

    Scale out replicas