-
Notifications
You must be signed in to change notification settings - Fork 715
Add support to enable automatic scaling for App Service Environment #12305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12305Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12305" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables automatic scaling for Azure App Service Plans by default to improve performance and avoid cold start issues. The change introduces a new WithAutomaticScaling extension method that allows customers to opt out if needed.
Key changes:
- Automatic scaling is now enabled by default for App Service Plans
- New
WithAutomaticScaling(bool)extension method allows disabling the feature - App Service Plan configuration now includes
elasticScaleEnabled,perSiteScaling, andmaximumElasticWorkerCountproperties - Dashboard configuration includes scale limit settings to ensure single-instance operation
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| AzureAppServiceEnvironmentExtensions.cs | Adds WithAutomaticScaling extension method and updates App Service Plan configuration logic |
| AzureAppServiceEnvironmentResource.cs | Adds EnableAutomaticScaling internal property with default value of true |
| AzureAppServiceEnvironmentUtility.cs | Updates dashboard site configuration to include scale limits |
| AzureAppServiceTests.cs | Adds test for disabling automatic scaling |
| *.verified.bicep | Updates snapshot tests to reflect new automatic scaling properties |
| /// <summary> | ||
| /// Configures whether automatic scaling should be enabled for the app services in Azure App Service environment. | ||
| /// </summary> | ||
| /// <param name="builder">The AzureAppServiceEnvironmentResource to configure.</param> | ||
| /// <param name="enable">Whether to enable automatic scaling. Default is true.</param> | ||
| /// <returns><see cref="IResourceBuilder{T}"/></returns> |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XML documentation is incomplete for a public API. According to Aspire's documentation standards, public APIs require comprehensive documentation including <remarks> and <example> sections. Add a <remarks> section explaining when/why to use this method and an <example> section showing practical usage with code.
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs
Show resolved
Hide resolved
| /// </summary> | ||
| /// <param name="builder">The AzureAppServiceEnvironmentResource to configure.</param> | ||
| /// <param name="enable">Whether to enable automatic scaling. Default is true.</param> | ||
| /// <returns><see cref="IResourceBuilder{T}"/></returns> |
Copilot
AI
Oct 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value documentation should follow the standard pattern for fluent APIs: "A reference to the <see cref="IResourceBuilder{T}"/> for chaining additional configuration."
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs
Show resolved
Hide resolved
|
@ShilpiRach thanks for the contribution. I'm not sure that we'll take this change but I'm interested in @davidfowl and @maddymontaquila for input. My issue with the change is really twofold:
Whilst we would want applications to be able to scale up, the app first needs to work correctly and its something that developers will need to assess on a case by case basis. |
|
@mitchdenny - is your main concern about making automatic scaling the default option? If yes, I am fine with making it non-default. Tagging @btardif to comment on your first comment about higher cost - who might have more data about this. For the 2nd point, Applications deployed on cloud should usually work with scaling out. But you might be right about existing Aspire customers trying out App Service. |
Made this change |
|
Thanks @ShilpiR. Just need to decide if we want to add this to the API surface now. We don't do these scaling options anywhere else. |
|
@mitchdenny - Autoscaling is a fundamental part of Azure App Service. What Shilpi is adding here is the platform detecting if the instance has too much load, it will scale out. Since Linux App Service does not have an autoheal feature, it basically means that if the instance becomes overloaded (because we are running atleast 6 containers, including Kudu which is a fairly heavyweight container), the app will just sit there in a bad state. And customers blame the platform rather than their app when this happens. I cannot comment on what other platforms provide. However, most App Service customers are used to autoscale and its one of our top-used features. This is an optional enablement, and we will document that it has a cost. We are also working on enabling autoscale by default for all sites created from the portal. |
|
@mitchdenny - For Azure Container Apps (ACA), consumption workload profile gets used in Aspire which automatically scales up, hence no separate option is needed. Scale out in Azure App Service, unlike ACA, is not enabled by default (though as @tulikac mentioned, we are working on enabling automatic scaling by default on portal). It is, however, strongly encouraged as a best practice. |
|
@mitchdenny just to underline what has already been said above:
Had a separate conversation with @davidfowl where I think he understands the need to have potentially different configs applied if this is the first time something is being executed, and resources are being created vs N time were you would want to omit most of the config so that you don't scale down an app that has been scaled out (either manually, through rules, or automatic scaling) due to existing load. CC: @tulikac @ShilpiRach |
|
/backport to release/13.0 |
|
Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/18961956932 |
|
@davidfowl backporting to "release/13.0" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Added autoscale option for App Service Environment
Using index info to reconstruct a base tree...
M src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs
M src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs
M src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs
CONFLICT (content): Merge conflict in src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs
Auto-merging src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs
CONFLICT (content): Merge conflict in src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentResource.cs
Auto-merging src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Added autoscale option for App Service Environment
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
Description
This PR adds support to enable automatic scaling for the Azure App Service Plan not enabled by default. This option is made available as it is considered a best practice to improve an app's performance and avoid cold start issues.
The change introduces an extension method
WithAutomaticScalingfor the AzureAppServiceEnvironment to enable automatic scaling. Customers can enable it withWithAutomaticScaling()orWithAutomaticScaling(true).Testing
WithAutomaticScaling(false)to ensure the properties related to PerSiteScaling are set correctly for the app service plan and app services.Relevant properties for App Service Plan:
Relevant properties for App Service
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate