1

Every time the update command runs, deletes the last Scale Rule, Custom type, a cron job and a memory utilization percentage set

The update command executes and it overlays the previous update, since the Azure Container App is already created. I want to update it after creation, with two or more scale rules (using just one script). How can I add that scale rules (two Custom types, one for Cron job and another one for memory utilization)?

How can I add them to the previously created Azure Container App, exists another kind of solution to add scale rules without using the update command (Azure CLI or Az Modules, other solutions)?

Or, if adding more than one scale rule after the Azure Container App, is creating it simply not possible?

For example, if I run this command again to add another scale rule it will overlay the previous one. How to fix this, if possible?

az containerapp update -n $name -g $rg --scale-rule-name $ruleName --scale-rule-type $customRuleType --scale-rule-metadata start=$start end=$end timezone=$timezone desiredReplicas=$desiredReplicas
2
  • when you run the az containerapp update command with a scale rule, it will replace the existing scale rules with the new one. Plus, Azure CLI does not currently support adding multiple scale rules in a single command directly. You would need to use the az containerapp update command for each scale rule, but this will overwrite the previous scale rules. Commented Nov 21, 2024 at 4:16
  • Found this on net- techcommunity.microsoft.com/blog/appsonazureblog/… and github.com/microsoft/azure-container-apps/issues/1040 Commented Nov 21, 2024 at 7:55

1 Answer 1

1

When working with Azure Container Apps, the az containerapp update command has a limitation where it replaces the scale section entirely with each execution. This behavior can make it tricky to manage multiple scaling rules, as adding a new rule through this command will overwrite any previously configured rules.

To address this, you can manage scaling rules effectively by using a YAML configuration file. Start by exporting the current configuration of your Azure Container App to a YAML file. This ensures that none of the existing settings or rules are lost.

az containerapp show -n sample-app -g arkorg --output yaml > containerapp-config.yaml

enter image description here

Open the exported containerapp-config.yaml and locate the scale section. Modify this section to include all the scaling rules you need.

scale:
  minReplicas: 1
  maxReplicas: 10
  rules:
    - name: cron-rule
      custom:
        type: cron
        metadata:
          start: "0 0 * * *"
          end: "0 1 * * *"
          timezone: "UTC"
          desiredReplicas: "2"
    - name: memory-rule
      custom:
        type: memory
        metadata:
          type: "Utilization"
          value: "75"

and do az containerapp update -n sample-app -g arkorg --yaml containerapp-config.yaml

enter image description here

enter image description here

At this time, Azure CLI does not support appending scale rules directly via individual commands. Every execution of az containerapp update replaces the existing scale section entirely. For now, managing scale rules through a YAML file is the most reliable approach.

Sign up to request clarification or add additional context in comments.

3 Comments

let me test 1st, im using Windows, you tested this ?, it will appear the two or more scale rules ? the command accepts the file config. ? is part of that command ? if the file is in the same folder of the script, enough to point it in the command ? TYsm,, after testing if it works i will accept.
this solution is not exactly what i was searching, i saw what you mean (is an idea), but i have to modify this file for each ACA and to do that in a single script, to update all of them in bulk, probably not possible, because the rest of the YAML file as to be accordingly with each one of the ACAs and just update the rules part, probably not possible to only send back the rules part, all of the file config. have to enter again, using the update command, am i right ? TY, answer accepted already
for cron custom scale rules, is it schedule or start/end that is required? i have tried both with no luck. i am trying to scale down to 0 outside of 6am-7pm, but doesnt do it. I notice u are using UTC. perhaps with chron it must be UTC as i was using region as America/New_York

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.