如何按计划扩展或缩小Azure App Service实例大小?

时间:2015-12-04 06:45:00

标签: azure azure-web-sites autoscaling azure-app-service-plans

在自动扩展Azure App Service时,我只找到以下内容。

Scale a web app in Azure App Service

这仅允许扩展到更多或更少的实例。它不允许扩展到越来越大的实例。

我想按计划安排小型,中型和大型之间的应用服务实例大小。是否有API可以让我这样做?

非常感谢。

6 个答案:

答案 0 :(得分:4)

很遗憾,目前无法按计划扩展Azure App Service实例大小(即应用服务计划定价层)。

截至目前,Azure App Service只能按计划支持水平扩展(即实例计数扩展),但不支持垂直扩展(即实例大小扩展)。

希望这有帮助!

答案 1 :(得分:4)

实际上,您可以自动扩展(垂直,即更改服务计划)以及输出(实例计数)。

横向扩展选项一直存在,允许您设置规则(例如CPU超过%,内存超过阈值等)

向上扩展选项需要使用Azure自动化。它已完整记录here

希望有所帮助!

答案 2 :(得分:4)

由于缺乏简单的解决方案,我创建了一个一键式部署来完成您所要的事情。

https://github.com/jraps20/jrap-AzureVerticalScaling

概述

我的方法使用Azure自动化运行手册。通过一键式部署方法,您可以在几分钟内完全启动并运行。两个互补的运行手册(ScaleAppServicePlansUp和ScaleAppServicePlansDown)一起工作以存储,读取和修改您选择的任何应用程序服务计划。这些操作手册的主要目标是非生产环境。

不幸的是,代码太长,无法包含在此答案中(因此,是的,这主要是仅链接的答案)。

伪代码

按比例缩小

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.

其他资源

免责声明

完成工作后,我意识到Sam Spoerles technique 。我的方法对他的好处如下:

答案 3 :(得分:1)

没有简单的方法可以做到这一点。

但是,如果您愿意编写一些代码,可以使用PowerShell api和Azure Automation为自己创建此功能。

您每隔X​​分钟使用apis检查指标(如CPU),如果CPU高于Y,则扩展到下一个更大的实例。如果它低于您的阈值,则缩小。

答案 4 :(得分:1)

使用PowerShell,您可以像这样切换网络应用的应用服务计划

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

此处服务器场ID只是服务计划的资源ID,您可以通过查看计划的属性从新门户获取该服务计划。

您可以有两个服务计划,一个是基本的,另一个是标准的。然后,您可以在工作日升级到标准,并使用Azure自动化在周末降级到基本。

我知道您的要求是更改现有计划本身而不是在计划之间切换。我想它应该是可能的,虽然我自己没有尝试过。但是,如果您浏览上面返回的Azure Web应用程序资源的Resource.Properties中返回的属性,您应该能够弄明白。

答案 5 :(得分:0)

我认为您正在寻找的是按计划或CPU类型的方式自动调度Azure WebApp

1.将您的主机方案更改为标准,您无法在标准层以下设置自动缩放。

2.在portal.azure.com上使用Azure预览门户。

3.Azure Preview Portal:正确的设置是使用“CPU百分比”

4.Azure Portal您可以将“按度量标准”从“无”设置为“CPU

5.将实例计数设置为1到4或8之间,稍后可以更改,最多可以达到10。

有关详细信息,请参阅此文http://blogs.msdn.com/b/devschool/archive/2015/05/24/azure-webjobs.aspx本文未讨论的内容是按计划进行扩展,我认为一旦达到目标,您就可以解决这个问题。 确保使用portal.azure.com