0
0
Azurecloud~30 mins

Auto scaling App Service in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Auto scaling App Service
📖 Scenario: You are managing a web application hosted on Azure App Service. To handle varying user traffic efficiently, you want to set up auto scaling. This means the app will automatically add or remove instances based on CPU usage, so it stays fast and cost-effective.
🎯 Goal: Build an Azure Resource Manager (ARM) template snippet that configures auto scaling for an Azure App Service plan. The scaling rule should increase instances when CPU usage is above 70% and decrease when below 30%.
📋 What You'll Learn
Create a resource group variable named resourceGroupName with the value MyResourceGroup.
Create a variable named appServicePlanName with the value MyAppServicePlan.
Define an autoscale setting resource named autoscaleSetting targeting the App Service plan.
Configure two scale rules: one to scale out when CPU > 70%, another to scale in when CPU < 30%.
💡 Why This Matters
🌍 Real World
Auto scaling helps web apps handle traffic spikes smoothly without manual intervention, saving cost and improving user experience.
💼 Career
Cloud engineers and DevOps professionals often configure autoscaling to ensure applications remain responsive and cost-efficient.
Progress0 / 4 steps
1
DATA SETUP: Define resource group and App Service plan variables
Create two variables: resourceGroupName set to "MyResourceGroup" and appServicePlanName set to "MyAppServicePlan".
Azure
Need a hint?

Use var to declare variables and assign the exact string values.

2
CONFIGURATION: Define autoscale setting resource basics
Create a JSON object named autoscaleSetting with name set to "autoscaleMyAppServicePlan", type set to "Microsoft.Insights/autoscaleSettings", and targetResourceUri set to the resource ID of the App Service plan using resourceGroupName and appServicePlanName.
Azure
Need a hint?

Use template literals with ${variable} to build the targetResourceUri.

3
CORE LOGIC: Add scale rules for CPU thresholds
Inside autoscaleSetting, add a profiles array with one profile named "AutoScaleProfile". Add two rules: one to increase capacity by 1 when CPU percentage is greater than 70, and one to decrease capacity by 1 when CPU percentage is less than 30. Use metric triggers on Percentage CPU and set timeAggregation to Average.
Azure
Need a hint?

Follow the Azure autoscale JSON schema for rules. Use metricTrigger and scaleAction objects inside each rule.

4
COMPLETION: Add location and finalize autoscale setting resource
Add a location property to autoscaleSetting with the value "eastus". Also add enabled set to true and notifications as an empty array. This completes the autoscale setting resource configuration.
Azure
Need a hint?

Add location, enabled, and notifications properties at the top level of autoscaleSetting.