|
| 1 | +--- |
| 2 | + |
| 3 | +title: Externally managed scheduled autoscaling for Application Gateway v2 |
| 4 | +description: This article introduces the Azure Application Standard_v2 and WAF_v2 SKU scheduled autoscaling feature. |
| 5 | +services: application-gateway |
| 6 | +author: greg-lindsay |
| 7 | +ms.service: application-gateway |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 10/30/2023 |
| 10 | +ms.author: greglin |
| 11 | + |
| 12 | +--- |
| 13 | +# Schedule autoscaling for Application Gateway v2 |
| 14 | + |
| 15 | +## Overview |
| 16 | + |
| 17 | +For those experiencing predictable daily traffic patterns and who have a reliable estimate of the required capacity for Application Gateway, the option to preschedule the minimum capacity to better align with traffic demands might be of interest. |
| 18 | + |
| 19 | +While autoscaling is commonly utilized, it’s important to note that Application Gateway doesn't currently support prescheduled capacity adjustments natively. |
| 20 | + |
| 21 | +The goal is to use Azure Automation to create a schedule for running runbooks that adjust the minimum autoscaling capacity of Application Gateway to meet traffic demands. |
| 22 | + |
| 23 | +## Set up scheduled autoscaling |
| 24 | + |
| 25 | +To implement scheduled autoscaling: |
| 26 | +1. Create an Azure Automation account resource in the same tenant as the Application Gateway. |
| 27 | +2. Note the system assigned managed identity of the Azure Automation account. |
| 28 | +3. Create PowerShell runbooks for increasing and decreasing min autoscaling capacity for the Application Gateway resource. |
| 29 | +4. Create the schedules during which the runbooks need to be implemented. |
| 30 | +5. Associate the runbooks with their respective schedules. |
| 31 | +6. Associate the system assigned managed identity noted in step 2 with the Application Gateway resource. |
| 32 | + |
| 33 | +## Configure automation |
| 34 | + |
| 35 | +Suppose the requirement is to increase the min count to 4 during business hours and to decrease the min count to 2 during non business hours. |
| 36 | + |
| 37 | +Two runbooks are created: |
| 38 | +- IncreaseMin - Sets the min count of the autoscaling configuration to 4 |
| 39 | +- DecreaseMin - Sets the min count of the autoscaling configuration to 2 |
| 40 | + |
| 41 | +Use the following PowerShell runbook to adjust capacity: |
| 42 | + |
| 43 | + ```Azure PowerShell |
| 44 | +# Get the context of the managed identity |
| 45 | +$context = (Connect-AzAccount -Identity).Context |
| 46 | +# Import the Az module |
| 47 | +Import-Module Az |
| 48 | +# Adjust the min count of your Application Gateway |
| 49 | +$gw = Get-AzApplicationGateway -Name “<AppGwName>” -ResourceGroupName “<ResourceGroupName>” |
| 50 | +$gw = Set-AzApplicationGatewayAutoscaleConfiguration -ApplicationGateway $gw -MinCapacity <NumberOfRequiredInstances> |
| 51 | +$gw = Set-AzApplicationGateway -ApplicationGateway $gw |
| 52 | +``` |
| 53 | + |
| 54 | +Next, create the following two schedules: |
| 55 | + |
| 56 | +- WeekdayMorning – Run the IncreaseMin runbook from Mon-Fri at 5:00AM PST |
| 57 | +- WeekdayEvening – Run the DecreaseMin runbook from Mon-Fri at 9:00PM PST |
| 58 | + |
| 59 | +## FAQs |
| 60 | + |
| 61 | +- What is the SLA for timely job executions? |
| 62 | + |
| 63 | + Azure Automation has a SLA of 99.9% for a timely start of jobs. |
| 64 | + |
| 65 | +- What happens if jobs are interrupted during execution? |
| 66 | + |
| 67 | + - If the job already sends the request to AppGW before getting interrupted, then the request goes through. |
| 68 | + - If the job gets interrupted before sending the request to Application Gateway, then it will be one of the scenarios described in next section. |
| 69 | + |
| 70 | +- What happens if job tasks don’t occur? |
| 71 | + |
| 72 | + | Absent job | Impact | |
| 73 | + | --- | --- | |
| 74 | + |IncreaseMin | Falls back on native autoscaling. Next run of DecreaseMin should be no-op as the count doesn’t need to be adjusted. | |
| 75 | + |DecreaseMin | Additional cost to the customer for the (unintended) capacity that is provisioned for those hours. Next run of IncreaseMin should be no-op because the count doesn’t need to be adjusted. | |
| 76 | + |
| 77 | +> [!NOTE] |
| 78 | +> Send email to [email protected] if you have questions or need help to set up managed and scheduled autoscale for your deployments. |
| 79 | +
|
| 80 | +## Next steps |
| 81 | + |
| 82 | +* Learn more about [Scaling Application Gateway v2 and WAF v2](application-gateway-autoscaling-zone-redundant.md) |
| 83 | +* Learn more about [Monitoring Azure Automation runbooks with metric alerts](../automation/automation-alert-metric.md) |
| 84 | +* Learn more about [Azure Automation](../automation/overview.md) |
0 commit comments