On auto scaling of Azure App Service, I only find the below.
Scale a web app in Azure App Service
This only allows for scaling to more or less instances. It does not allow for scaling to bigger and smaller instances.
I want to schedule an app service instance size between small, medium, and large on a schedule. Is there an API that will allow me to do this?
Thank you much.
To scale down, go to Azure web application and select Scale up (App Service plan). The selected pricing tier will have a blue border around it. Change the lower pricing tier based on your requirements. Click on Select.
Unfortunately, there is no way to scale the Azure App Service instance size (i.e. the App Service Plan Pricing Tiers) on a schedule basis at this time.
Azure App Service has built-in autoscaling. Autoscale settings apply to all of the apps within an App Service. See Scale instance count manually or automatically and Scale up an app in Azure App Service. Azure Cloud Services has built-in autoscaling at the role level.
Due to the lack of a simple solution, I created a one-click deploy to do what you're asking.
https://github.com/jraps20/jrap-AzureVerticalScaling
My approach uses Azure Automation Runbooks. Via the one-click deploy method you can get fully up and running in a few minutes. The two complementary runbooks (ScaleAppServicePlansUp and ScaleAppServicePlansDown) work together to store, read and modify whichever App Service Plans you choose. The primary target for these runbooks are non-prod environments.
The code is too long to include in this answer, unfortunately (so yes, this will mostly be a link-only answer).
Iterate across all Resource Groups (or pass in specific one)
Iterate across all App Service Plans (or pass in specific one)
Iterate across all App Services (identify Tier-specific settings)
During iteration, the current App Service Plan Service Tier is stored in Azure Automation Variables (3 distinct variables for each App Service Plan)
Within each App Service Plan, each App Service is iterated to identify tier-specific settings. Some of these settings include: AlwaysOn, Use32BitWorkerProcess, and ClientCertEnabled. All current settings are stored in Azure Automation Variables.
All App Service Plans are then scaled down to the FREE tier.
Iterate across all Resource Groups (or pass in specific one)
Iterate across all App Service Plans (or pass in specific one)
Iterate across all App Services (identify Tier-specific settings)
During iteration, the original App Service Plan Service Tier is retrieved from Azure Automation Variables (3 distinct variables for each App Service Plan)
Within each App Service Plan, each App Service is iterated and any previously stored tier-specific settings are retrieved.
All App Service Plans are then scaled up to their original tier.
All App Services with tier-specific settings are reapplied to their original values.
I became aware of Sam Spoerles technique after completing my work. The benefits of my approach over his are as follows:
Unfortunately, there is no way to scale the Azure App Service instance size (i.e. the App Service Plan Pricing Tiers) on a schedule basis at this time.
As of now, Azure App Service can only support horizontal scaling (i.e. instance count scaling) on a schedule basis but not for the vertical scaling (i.e. instance size scaling).
Hope this helps!
Actually you can scale up (vertically, i.e. change the service plan) as well as out (instance count) automatically.
The scale out option has been there forever and allows you to setup rules (e.g. CPU exceeds %, memory goes over threshold, etc.)
The scale up option requires using Azure Automation. It's fully documented here
Hope that helps!
There is no easy way to do that.
However, if you're willing to write some code you could use the PowerShell api with Azure Automation to create this functionality for yourself.
You'd use the apis to check the metrics (like CPU) every X minutes, and if the CPU is higher than Y scale up to the next larger instance. If it's below your threshold, then scale down.
Using powershell, you can switch the app service plan of a web app like this
PS C:\> $Resource = Get-AzureRmResource -ResourceType "microsoft.web/sites" -ResourceGroupName "ResourceGroup11" -ResourceName "ContosoSite"
PS C:\> $Resource.Properties.ServerFarmId = "/subscriptions/{subscr_id}/resourceGroups/FriendsRGrp/provider
s/Microsoft.Web/serverfarms/FriendsPlan"
PS C:\> $Resource | Set-AzureRmResource -Force
Here the server farm id is nothing but the resource id of the service plan which you can get from the new portal, by looking at the properties of the plan.
You can have two service plans one with basic and another with standard. You can then upgrade to standard during weekdays and downgrade to basic on weekends using Azure Automation.
I understand that you're requirement is to change the existing plan itself and not to switch between plans. I'm thinking that it should be possible, although I haven't tried it myself. But if you go through the properties returned in the Resource.Properties of the returned Azure web app resource as above, you should be able to figure it out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With