Get started with auto scale by custom metric in Azure

This article describes how to scale your resource by a custom metric in Azure portal.

Azure Monitor autoscale applies only to Virtual Machine Scale Sets, Cloud Services, App Service - Web Apps, Azure Data Explorer Cluster , Integration Service Environment and API Management services.

Lets get started

This article assumes that you have a web app with application insights configured. If you don't have one already, you can set up Application Insights for your ASP.NET website

  • Open Azure portal
  • Click on Azure Monitor icon in the left navigation pane. Launch Azure Monitor
  • Click on Autoscale setting to view all the resources for which auto scale is applicable, along with its current autoscale status Discover auto scale in Azure monitor
  • Open 'Autoscale' blade in Azure Monitor and select a resource you want to scale

    Note: The steps below use an app service plan associated with a web app that has app insights configured.

  • In the scale setting blade for the resource, notice that the current instance count is 1. Click on 'Enable autoscale'. Scale setting for new web app
  • Provide a name for the scale setting, and the click on "Add a rule". Notice the scale rule options that opens as a context pane in the right hand side. By default, it sets the option to scale your instance count by 1 if the CPU percentage of the resource exceeds 70%. Change the metric source at the top to "Application Insights", select the app insights resource in the 'Resource' dropdown and then select the custom metric based on which you want to scale. Scale by custom metric
  • Similar to the step above, add a scale rule that will scale in and decrease the scale count by 1 if the custom metric is below a threshold. Scale based on cpu
  • Set the instance limits. For example, if you want to scale between 2-5 instances depending on the custom metric fluctuations, set 'minimum' to '2', 'maximum' to '5' and 'default' to '2'

    Note: In case there is a problem reading the resource metrics and the current capacity is below the default capacity, then to ensure the availability of the resource, Autoscale will scale out to the default value. If the current capacity is already higher than default capacity, Autoscale will not scale in.

  • Click on 'Save'

Congratulations. You now successfully created your scale setting to auto scale your web app based on a custom metric.

Note: The same steps are applicable to get started with a VMSS or cloud service role.