The symptom is one of these: CPU has been at 90% for twenty minutes and the scale set is still at the same instance count; it scaled out last night and never came back in; or it bounces between counts every few minutes. Autoscale is a separate resource (Microsoft.Insights/autoscaleSettings) that points at the scale set, so most of the answers are in that resource and its logs, not on the VMs.
The examples use resource group rg-web, scale set vmss-web and an autoscale setting called as-vmss-web.
Quick map: symptom to cause
| Symptom | Likely cause | Fix |
|---|---|---|
| Never scales out, count equals maximum | maximum in the active profile reached | Raise the maximum, check quota first |
| Never scales out, count below maximum | Setting disabled, wrong profile active, metric never crosses threshold | Enable, check profile schedule, check metric values |
| Scale action starts and fails | Quota, AllocationFailed, SKU not available in zone | Request quota, change size or zones |
| Scales out but never scales in | No scale-in rule, or flapping protection blocks it | Add a scale-in rule with a wider gap |
| Scale-in waits far longer than expected | Several scale-in rules: all must be true | Simplify or align scale-in rules |
| Count jumps back after you change it manually | Autoscale enforces min/max/default | Change the profile, not the capacity |
| Guest metric rule does nothing | Metric not emitted to the namespace used in the rule | Fix diagnostics/metric namespace or use a host metric |
Check 1: is autoscale on, and pointed at this scale set?
az monitor autoscale show -g rg-web -n as-vmss-web \
--query "{enabled:enabled, target:targetResourceUri, profiles:profiles[].{name:name, min:capacity.minimum, max:capacity.maximum, default:capacity.default, recurrence:recurrence, fixedDate:fixedDate}}" -o json
If you don't know the setting name, list them in the resource group and match targetResourceUri:
az monitor autoscale list -g rg-web \
--query "[].{name:name, enabled:enabled, target:targetResourceUri}" -o table
Look for three things:
enabledisfalse. People disable autoscale during an incident and forget to turn it back on.targetResourceUripoints at an old scale set that was rebuilt under the same name in another resource group.- The current instance count already equals
maximumfor the profile that is active right now.
Check the current count to compare:
az vmss show -g rg-web -n vmss-web --query "sku.capacity"
Check 2: which profile is actually active?
An autoscale setting can have a default profile plus recurring (for example "weekdays 08:00–18:00") and fixed-date profiles. Only one profile is in force at a time. A recurring "night" profile with maximum: 2 will cap you at two instances, whatever the default profile says.
az monitor autoscale profile list -g rg-web --autoscale-name as-vmss-web -o json
Check the time zone on each recurrence. A profile written for W. Europe Standard Time that someone copied into an Asia deployment fires at the wrong hours. The ProfileSelected field in the evaluation logs (Check 5) tells you which profile autoscale chose at each run.
Check 3: do the rules make sense?
az monitor autoscale rule list -g rg-web --autoscale-name as-vmss-web -o table
Then pull the real metric values for the same window and aggregation the rule uses:
VMSS_ID=$(az vmss show -g rg-web -n vmss-web --query id -o tsv)
az monitor metrics list --resource "$VMSS_ID" \
--metric "Percentage CPU" --interval PT5M --aggregation Average \
--offset 2h -o table
Things that break rules:
- Averaging hides the peak. The rule averages across all instances. One instance at 100% and five at 20% averages to about 33%, which won't trip a 70% threshold. If one node is hot, look at load balancing or session affinity, not autoscale.
- Guest metrics with no data. Rules on in-guest counters (memory, disk queue) need the metric to arrive in the namespace the rule references. If the metric has no data points, the rule never fires. Check with
az monitor metrics list-definitions --resource "$VMSS_ID", and prefer host metrics such asPercentage CPUwhen they're good enough. - Scale-out vs scale-in logic. Autoscale scales out if any scale-out rule is met, but scales in only when all scale-in rules are met. Three scale-in rules on different metrics can mean it almost never scales in.
- Cooldown. After a scale action, rules are skipped until the cooldown expires. A 30-minute cooldown on scale-out means a slow response to a sharp spike.
A sane starting pair for a web tier:
az monitor autoscale rule create -g rg-web --autoscale-name as-vmss-web \
--condition "Percentage CPU > 70 avg 10m" --scale out 2 --cooldown 5
az monitor autoscale rule create -g rg-web --autoscale-name as-vmss-web \
--condition "Percentage CPU < 30 avg 15m" --scale in 1 --cooldown 10
Check 4: did a scale action start and fail?
Autoscale writes events to the Activity Log under the Autoscale category. A failed scale-out shows up there even when the setting itself looks fine.
az monitor activity-log list -g rg-web --offset 1d \
--query "[?category.value=='Autoscale'].{time:eventTimestamp, op:operationName.localizedValue, status:status.value, desc:description}" -o table
Then check the scale set's own operations for the underlying error:
az monitor activity-log list --resource-id "$VMSS_ID" --offset 1d \
--query "[?status.value=='Failed'].{time:eventTimestamp, op:operationName.value, msg:properties.statusMessage}" -o json
Common errors here are OperationNotAllowed with a quota message (regional or VM family vCPU quota), AllocationFailed / ZonalAllocationFailed, and SkuNotAvailable. Check usage against quota:
az vm list-usage --location westeurope -o table
Warning
Raising
maximumwithout checking quota just moves the failure to the next scale event. Check the family vCPU quota and regional quota for the new maximum before you change the profile.
Check 5: read the autoscale resource logs
The Activity Log tells you a scale action happened. It doesn't tell you why autoscale decided not to act. For that, turn on the autoscale resource logs (categories AutoscaleEvaluations and AutoscaleScaleActions) to a Log Analytics workspace:
AS_ID=$(az monitor autoscale show -g rg-web -n as-vmss-web --query id -o tsv)
az monitor diagnostic-settings create --name autoscale-to-law \
--resource "$AS_ID" \
--workspace "/subscriptions/<sub-id>/resourceGroups/rg-mon/providers/Microsoft.OperationalInsights/workspaces/law-ops" \
--logs '[{"category":"AutoscaleEvaluations","enabled":true},{"category":"AutoscaleScaleActions","enabled":true}]'
Data lands in the AutoscaleEvaluationsLog and AutoscaleScaleActionsLog tables. Confirm the columns on your workspace first:
AutoscaleEvaluationsLog | getschema
Scale actions and their results:
AutoscaleScaleActionsLog
| where TimeGenerated > ago(24h)
| project TimeGenerated, OperationName, ResultType, NewInstanceCount, ResultDescription
| order by TimeGenerated desc
Evaluations, to see which profile was chosen and whether cooldown skipped the rules:
AutoscaleEvaluationsLog
| where TimeGenerated > ago(6h)
| project TimeGenerated, OperationName, ProfileSelected, SkipRuleEvaluationForCooldown, ResultDescription
| order by TimeGenerated desc
| take 200
The evaluation entries also record the observed metric value against the threshold and any flapping decision. Field names vary, so check getschema and the ResultDescription text.
Tip
The logs talk about "scale up" and "scale down". For a scale set, autoscale always scales out and in: it adds or removes instances and never changes the VM size.
Scales out but never scales in: flapping
Before it scales in, autoscale works out what the metric would be on the smaller instance count. If that estimate would immediately trip the scale-out rule, it skips the scale-in. This is flapping protection. With "out above 60%, in below 50%" on four instances at 45%, removing one instance projects 60%, so it stays at four.
Fix it by leaving a wide gap between thresholds (for example out at 70%, in at 30%) and scaling in by one instance at a time. The evaluation log records when flapping was the reason for skipping.
Manual changes get undone
If you run az vmss scale --new-capacity 10 while autoscale is enabled with maximum: 6, autoscale brings it back to 6 at the next evaluation. For a planned event, change the profile:
az monitor autoscale update -g rg-web -n as-vmss-web --min-count 8 --max-count 20 --count 8
Or add a fixed-date profile for the event window so the default comes back by itself afterwards.
Caution
Lowering
minimumormaximumbelow the current count triggers a scale-in at the next evaluation. On stateful or session-heavy tiers, use instance protection (az vmss update -g rg-web -n vmss-web --instance-id 3 --protect-from-scale-in true) on instances that must stay, and check how your app handles connection draining.
Prevent it next time
- Alert on Activity Log
Autoscaleevents with statusFailed, and on the scale set sitting atmaximumfor more than 30 minutes. - Keep autoscale resource logs on in production; they are the only record of why it didn't act.
- Use one scale-out rule and one scale-in rule per metric, with a wide threshold gap.
- Check vCPU quota headroom for the full
maximumas part of every capacity review. - Keep autoscale settings in Bicep/Terraform so profiles and time zones are reviewed, not hand-edited during incidents.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get