Question

Difficulty: HardScale Azure App Service Web Apps

An organization hosts a report generation web application named contoso-reports on an Azure App Service Web App. The web application currently runs on an App Service plan named asp-free using the Free (F1) pricing tier.

During scheduled weekly report generation, the web application experiences severe CPU spikes that cause performance degradation. You need to implement an autoscale strategy using the Azure CLI that meets the following requirements:
- The hosting plan must be changed to the lowest cost tier that supports autoscale rules.
- The instance count must scale out by 1 instance when average CPU utilization is greater than 85% for 10 minutes.
- The instance count must scale in by 1 instance when average CPU utilization drops below 40% for 10 minutes.
- The configuration must prevent autoscale flapping.

Which four Azure CLI commands should you execute in sequence? To answer, move the appropriate commands from the list of commands to the answer area and arrange them in the correct order. (Note: Configure the scale-out rule before the scale-in rule.)

  1. 1az appservice plan update --name asp-free --resource-group rg-reports --sku S1
  2. 2az monitor autoscale create --resource-group rg-reports --resource asp-free --resource-type Microsoft.Web/serverfarms --name autoscale-reports --min-count 1 --max-count 4 --count 1
  3. 3az monitor autoscale rule create --resource-group rg-reports --autoscale-name autoscale-reports --scale out 1 --condition "CpuPercentage > 85 avg 10m"
  4. 4az monitor autoscale rule create --resource-group rg-reports --autoscale-name autoscale-reports --scale in 1 --condition "CpuPercentage < 40 avg 10m"

Answer

To configure autoscale for the web app, you must first update the App Service plan SKU to S1 to support autoscale. Next, create the autoscale setting on the plan. Finally, configure the scale-out rule followed by the scale-in rule.
The correct order begins with scaling up the App Service plan from Free (F1) to Standard (S1) using 'az appservice plan update' because autoscaling is not supported on the Free tier. Next, you must create the autoscale setting container using 'az monitor autoscale create' before you can add rules to it. After creating the setting container, you add the scale-out rule to handle CPU spikes, and finally, you add the scale-in rule with a 40% threshold to prevent autoscale flapping when the load drops.

Step-by-Step Solution

1
Scale up the App Service plan to the Standard (S1) tier.
The plan is updated to a SKU that supports custom autoscale rules.
The Free (F1) tier does not support autoscale features; Standard (S1) is the lowest pricing tier that supports custom autoscale.
2
Create the autoscale setting container.
An autoscale setting named autoscale-reports is created and linked to the App Service plan.
You cannot add rules without first creating an autoscale setting that defines the base instance limits.
3
Create the scale-out rule.
A scale-out rule is added to autoscale-reports to increase instances by 1 when average CPU exceeds 85% for 10 minutes.
This rule allows the web app to scale out during CPU spikes to maintain performance.
4
Create the scale-in rule.
A scale-in rule is added to autoscale-reports to decrease instances by 1 when average CPU is below 40% for 10 minutes.
This rule reduces costs when the CPU spikes subside, and the 40% threshold prevents flapping.

Key Concept

Scaling Azure App Service plans using the Azure CLI
Rate this question