Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Scaling your resources for a particular day of the week, or a specific date and time can reduce your costs while still providing the capacity you need when you need it.
You can use multiple profiles in autoscale to scale in different ways at different times. If for example, your business isn't active on the weekend, create a recurring profile to scale in your resources on Saturdays and Sundays. If black Friday is a busy day, create a profile to automatically scale out your resources on black Friday.
This article explains the different profiles in autoscale and how to use them.
You can have one or more profiles in your autoscale setting.
There are three types of profile:
- The default profile. The default profile is created automatically and isn't dependent on a schedule. The default profile can't be deleted. The default profile is used when there are no other profiles that match the current date and time.
- Recurring profiles. A recurring profile is valid for a specific time range and repeats for selected days of the week.
- Fixed date and time profiles. A profile that is valid for a time range on a specific date.
Each time the autoscale service runs, the profiles are evaluated in the following order:
- Fixed date profiles
- Recurring profiles
- Default profile
If a profile's date and time settings match the current time, autoscale applies that profile's rules and capacity limits. Only the first applicable profile is used.
The following example shows an autoscale setting with a default profile and recurring profile.
In the example above, on Monday after 3 AM, the recurring profile will cease to be used. If the instance count is less than 3, autoscale scales to the new minimum of three. Autoscale continues to use this profile and scales based on CPU% until Monday at 8 PM. At all other times scaling is done according to the default profile, based on the number of requests. After 8 PM on Monday, autoscale switches to the default profile. If for example, the number of instances at the time is 12, autoscale scales in to 10, which the maximum allowed for the default profile.
Autoscale transitions between profiles based on their start times. The end time for a given profile is determined by the start time of the following profile.
In the portal, the end time field becomes the next start time for the default profile. You can't specify the same time for the end of one profile and the start of the next. The portal forces the end time to be one minute before the start time of the following profile. During this minute, the default profile becomes active. If you don't want the default profile to become active between recurring profiles, leave the end time field empty.
Tip
To set up multiple contiguous profiles using the portal, leave the end time empty. The current profile will stop being used when the next profile becomes active. Only specify an end time when you want to revert to the default profile. Creating a recurring profile with no end time is only supported via the portal and ARM templates.
When creating multiple profiles using templates, the CLI, and PowerShell, follow the guidelines below.
PowerShell can be used to create multiple profiles in your autoscale settings.
See the PowerShell Az PowerShell module.Monitor Reference for the full set of autoscale PowerShell commands.
The following steps show how to create an autoscale profile using PowerShell.
- Create rules using
New-AzAutoscaleRule
. - Create profiles using
New-AzAutoscaleProfile
using the rules from the previous step. - Use
Add-AzAutoscaleSetting
to apply the profiles to your autoscale setting.
The following example shows how to create default profile and a recurring autoscale profile, recurring on Wednesdays and Fridays between 09:00 and 23:00.
The default profile uses the CpuIn
and CpuOut
Rules. The recurring profile uses the BandwidthIn
and BandwidthOut
rules.
Set-AzureSubscription -SubscriptionId "aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e"
$ResourceGroupName="rg-vmss-001"
$TargetResourceId="/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-vmss-001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss-001"
$ScaleSettingName="vmss-autoscalesetting=001"
$CpuOut=New-AzAutoscaleScaleRuleObject `
-MetricTriggerMetricName "Percentage CPU" `
-MetricTriggerMetricResourceUri "$TargetResourceId" `
-MetricTriggerTimeGrain ([System.TimeSpan]::New(0,1,0)) `
-MetricTriggerStatistic "Average" `
-MetricTriggerTimeWindow ([System.TimeSpan]::New(0,5,0)) `
-MetricTriggerTimeAggregation "Average" `
-MetricTriggerOperator "GreaterThan" `
-MetricTriggerThreshold 50 `
-MetricTriggerDividePerInstance $false `
-ScaleActionDirection "Increase" `
-ScaleActionType "ChangeCount" `
-ScaleActionValue 1 `
-ScaleActionCooldown ([System.TimeSpan]::New(0,5,0))
$CpuIn=New-AzAutoscaleScaleRuleObject `
-MetricTriggerMetricName "Percentage CPU" `
-MetricTriggerMetricResourceUri "$TargetResourceId" `
-MetricTriggerTimeGrain ([System.TimeSpan]::New(0,1,0)) `
-MetricTriggerStatistic "Average" `
-MetricTriggerTimeWindow ([System.TimeSpan]::New(0,5,0)) `
-MetricTriggerTimeAggregation "Average" `
-MetricTriggerOperator "LessThan" `
-MetricTriggerThreshold 30 `
-MetricTriggerDividePerInstance $false `
-ScaleActionDirection "Decrease" `
-ScaleActionType "ChangeCount" `
-ScaleActionValue 1 `
-ScaleActionCooldown ([System.TimeSpan]::New(0,5,0))
$defaultProfile=New-AzAutoscaleProfileObject `
-Name "Default" `
-CapacityDefault 1 `
-CapacityMaximum 5 `
-CapacityMinimum 1 `
-Rule $CpuOut, $CpuIn
$BandwidthIn=New-AzAutoscaleScaleRuleObject `
-MetricTriggerMetricName "VM Cached Bandwidth Consumed Percentage" `
-MetricTriggerMetricResourceUri "$TargetResourceId" `
-MetricTriggerTimeGrain ([System.TimeSpan]::New(0,1,0)) `
-MetricTriggerStatistic "Average" `
-MetricTriggerTimeWindow ([System.TimeSpan]::New(0,5,0)) `
-MetricTriggerTimeAggregation "Average" `
-MetricTriggerOperator "LessThan" `
-MetricTriggerThreshold 30 `
-MetricTriggerDividePerInstance $false `
-ScaleActionDirection "Decrease" `
-ScaleActionType "ChangeCount" `
-ScaleActionValue 1 `
-ScaleActionCooldown ([System.TimeSpan]::New(0,5,0))
$BandwidthOut=New-AzAutoscaleScaleRuleObject `
-MetricTriggerMetricName "VM Cached Bandwidth Consumed Percentage" `
-MetricTriggerMetricResourceUri "$TargetResourceId" `
-MetricTriggerTimeGrain ([System.TimeSpan]::New(0,1,0)) `
-MetricTriggerStatistic "Average" `
-MetricTriggerTimeWindow ([System.TimeSpan]::New(0,5,0)) `
-MetricTriggerTimeAggregation "Average" `
-MetricTriggerOperator "GreaterThan" `
-MetricTriggerThreshold 60 `
-MetricTriggerDividePerInstance $false `
-ScaleActionDirection "Increase" `
-ScaleActionType "ChangeCount" `
-ScaleActionValue 1 `
-ScaleActionCooldown ([System.TimeSpan]::New(0,5,0))
$RecurringProfile=New-AzAutoscaleProfileObject `
-Name "Wednesdays and Fridays" `
-CapacityDefault 1 `
-CapacityMaximum 10 `
-CapacityMinimum 1 `
-RecurrenceFrequency week `
-ScheduleDay "Wednesday","Friday" `
-ScheduleHour 09 `
-ScheduleMinute 00 `
-ScheduleTimeZone "Pacific Standard Time" `
-Rule $BandwidthIn, $BandwidthOut
$DefaultProfile2=New-AzAutoscaleProfileObject `
-Name "Back to default after Wednesday and Friday" `
-CapacityDefault 1 `
-CapacityMaximum 5 `
-CapacityMinimum 1 `
-RecurrenceFrequency week `
-ScheduleDay "Wednesday","Friday" `
-ScheduleHour 23 `
-ScheduleMinute 00 `
-ScheduleTimeZone "Pacific Standard Time" `
-Rule $CpuOut, $CpuIn
Update-AzAutoscaleSetting `
-name $ScaleSettingName `
-ResourceGroup $ResourceGroupName `
-Enabled $true `
-TargetResourceUri $TargetResourceId `
-Profile $DefaultProfile, $RecurringProfile, $DefaultProfile2
Note
You can't specify an end date for recurring profiles in PowerShell. To end a recurring profile, create a copy of default profile with the same recurrence parameters as the recurring profile. Set the start time to be the time you want the recurring profile to end. Each recurring profile requires its own copy of the default profile to specify an end time.
If you have multiple recurring profiles and want to change your default profile, the change must be made to each default profile corresponding to a recurring profile.
For example, if you have two recurring profiles called SundayProfile and ThursdayProfile, you need two New-AzAutoscaleProfile
commands to change to the default profile.
$DefaultProfileSundayProfile = New-AzAutoscaleProfile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rule $CpuOut,$CpuIn -Name "Defalut for Sunday" -RecurrenceFrequency week -ScheduleDay "Sunday" -ScheduleHour 19 -ScheduleMinute 00 -ScheduleTimeZone "Pacific Standard Time"`
$DefaultProfileThursdayProfile = New-AzAutoscaleProfile -DefaultCapacity "1" -MaximumCapacity "10" -MinimumCapacity "1" -Rule $CpuOut,$CpuIn -Name "Default for Thursday" -RecurrenceFrequency week -ScheduleDay "Thursday" -ScheduleHour 19 -ScheduleMinute 00 -ScheduleTimeZone "Pacific Standard Time"`
- Autoscale CLI reference
- ARM template resource definition
- PowerShell Az PowerShell module.Monitor Reference
- REST API reference. Autoscale Settings.
- Tutorial: Automatically scale a Virtual Machine Scale Set with an Azure template
- Tutorial: Automatically scale a Virtual Machine Scale Set with the Azure CLI
- Tutorial: Automatically scale a Virtual Machine Scale Set with an Azure template