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
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
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
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.