为 Azure 应用服务配置 PremiumV2 层Configure PremiumV2 tier for Azure App Service

与现有定价层相比,新的 PremiumV2 定价层提供更快的处理器和 SSD 存储以及双倍的内存-内核比 。The new PremiumV2 pricing tier gives you faster processors, SSD storage, and doubles the memory-to-core ratio of the existing pricing tiers. 借助性能优势,可以通过在更少的实例上运行应用来节省资金。With the performance advantage, you could save money by running your apps on fewer instances. 在本文中,你将了解如何在 PremiumV2 层中创建应用或者将应用纵向扩展到 PremiumV2 层。In this article, you learn how to create an app in PremiumV2 tier or scale up an app to PremiumV2 tier.

必备条件Prerequisites

若要将应用纵向扩展到 PremiumV2,需要有一个 Azure 应用服务应用,该应用在低于 PremiumV2 的定价层中运行,并且必须在支持 PremiumV2 的应用服务部署中运行。To scale-up an app to PremiumV2, you need to have an Azure App Service app that runs in a pricing tier lower than PremiumV2, and the app must be running in an App Service deployment that supports PremiumV2.

PremiumV2 可用性PremiumV2 availability

PremiumV2 层适用于 WindowsLinux 上的应用服务。The PremiumV2 tier is available for App Service on both Windows as well as Linux.

PremiumV2 已在大多数 Azure 区域中推出。PremiumV2 is available in most Azure regions. 若要查看它在你所在的区域是否可用,请在 Azure CLI 中运行以下 Azure CLI 命令:To see if it's available in your region, run the following Azure CLI command in the Azure CLI:

az appservice list-locations --sku P1V2

在 PremiumV2 层中创建应用Create an app in PremiumV2 tier

应用服务应用的定价层是在运行它的应用服务计划中定义的。The pricing tier of an App Service app is defined in the App Service plan that it runs on. 应用服务计划可以独立创建,也可以在创建应用的过程中创建。You can create an App Service plan by itself or as part of app creation.

Azure 门户中配置应用服务计划时,选择“定价层”。 When configuring the App Service plan in the Azure portal, select Pricing tier.

选择“生产” ,然后选择 P1V2P2V2P3V2,然后单击“应用” 。Select Production, then select P1V2, P2V2, or P3V2, then click Apply.

屏幕截图,显示应用的建议定价层。

重要

如果未看到 P1V2P2V2P3V2 作为选项列出,或者这些选项灰显,则 PremiumV2 可能在包含应用服务计划的基础应用服务部署中不可用。If you don't see P1V2, P2V2, and P3V2 as options, or if the options are greyed out, then PremiumV2 likely isn't available in the underlying App Service deployment that contains the App Service plan. 有关更多详细信息,请参阅从不受支持的资源组和区域组合纵向扩展See Scale up from an unsupported resource group and region combination for more details.

将现有应用纵向扩展到 PremiumV2 层Scale up an existing app to PremiumV2 tier

在将现有应用扩展到 PremiumV2 层之前,请确保 PremiumV2 可用。Before scaling an existing app to PremiumV2 tier, make sure that PremiumV2 is available. 有关信息,请参阅 PremiumV2 可用性For information, see PremiumV2 availability. 如果 PremiumV2 不可用,请参阅从不受支持的资源组和区域组合纵向扩展If it's not available, see Scale up from an unsupported resource group and region combination.

根据托管环境,纵向扩展可能需要执行额外的步骤。Depending on your hosting environment, scaling up may require extra steps.

Azure 门户中,打开你的应用服务应用页面。In the Azure portal, open your App Service app page.

在应用服务应用页面的左侧导航栏中,选择“纵向扩展(应用服务计划)”。****In the left navigation of your App Service app page, select Scale up (App Service plan).

屏幕截图,显示如何纵向扩展应用服务计划。

选择“生产”****,然后选择 P1V2P2V2P3V2,然后单击“应用”****。Select Production, then select P1V2, P2V2, or P3V2, then click Apply.

屏幕截图,显示应用的建议定价层。

如果操作成功完成,则应用的概述页会显示它目前处于 PremiumV2 层中。If your operation finishes successfully, your app's overview page shows that it's now in a PremiumV2 tier.

屏幕截图,显示应用的概览页上的 PremiumV2 定价层。

如果遇到错误If you get an error

如果基础应用服务部署不支持 PremiumV2,某些应用服务计划无法纵向扩展到 PremiumV2 层。Some App Service plans can't scale up to the PremiumV2 tier if the underlying App Service deployment doesn’t support PremiumV2. 有关更多详细信息,请参阅从不受支持的资源组和区域组合纵向扩展See Scale up from an unsupported resource group and region combination for more details.

从不受支持的资源组和区域组合纵向扩展Scale up from an unsupported resource group and region combination

如果应用在不支持 PremiumV2 的应用服务部署中运行,或者在目前不支持 PremiumV2 的区域中运行,则需要重新部署应用才能利用 PremiumV2If your app runs in an App Service deployment where PremiumV2 isn't available, or if your app runs in a region that currently does not support PremiumV2, you will need to re-deploy your app to take advantage of PremiumV2. 可以使用两个选项:You have two options:

  • 创建资源组,然后在资源组中创建应用和应用服务计划,并在创建过程中选择所需的 Azure 区域。Create a new resource group, and then create a new app and App Service plan in the new resource group, choosing your desired Azure region during the creation process. 创建新应用服务计划时,必须选择 PremiumV2 计划。You must select the PremiumV2 plan at the time the new app service plan is created. 这可以确保资源组、应用服务计划和 Azure 区域的组合可让你在支持 PremiumV2 的应用服务部署中创建应用服务计划。This ensures the combination of resource group, App Service plan, and Azure region will result in the App Service plan being created in an App Service deployment that supports PremiumV2. 然后,将应用程序代码重新部署到新建的应用和应用服务计划。Then redeploy your application code into the newly created app and app service plan. 以后可以根据需要,将应用服务计划从 PremiumV2 纵向缩减以节省成本,同时仍可使用 PremiumV2 成功纵向扩展。If desired you can subsequently scale the App Service plan down from PremiumV2 to save costs, and you will still be able to successfully scale back up again in the future using PremiumV2.

  • 如果应用已在现有的高级层中运行,则可将应用以及所有应用设置、连接字符串和部署配置克隆到使用 PremiumV2 的新应用服务计划。If your app already runs in an existing Premium tier, then you can clone your app with all app settings, connection strings, and deployment configuration into a new app service plan that uses PremiumV2.

    屏幕截图,显示如何克隆应用。

    在“克隆应用”页中,可以在所需的区域中创建使用 PremiumV2 的应用服务计划,并指定要克隆的应用设置和配置。****In the Clone app page, you can create an App Service plan using PremiumV2 in the region you want, and specify the app settings and configuration that you want to clone.

使用脚本自动化Automate with scripts

可以使用 Azure CLIAzure PowerShell 通过脚本在 PremiumV2 层中自动执行应用创建。You can automate app creation in the PremiumV2 tier with scripts, using the Azure CLI or Azure PowerShell.

Azure CLIAzure CLI

以下命令在 P1V2 中创建应用服务计划。The following command creates an App Service plan in P1V2. 可以在 Azure CLI 中运行它。You can run it in the Azure CLI. 用于 --sku 的选项有 P1V2、P2V2P3V2The options for --sku are P1V2, P2V2, and P3V2.

az appservice plan create \
    --resource-group <resource_group_name> \
    --name <app_service_plan_name> \
    --sku P1V2

Azure PowerShellAzure PowerShell

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

以下命令在 P1V2 中创建应用服务计划。The following command creates an App Service plan in P1V2. 用于 -WorkerSize 的选项有 SmallMediumLargeThe options for -WorkerSize are Small, Medium, and Large.

New-AzAppServicePlan -ResourceGroupName <resource_group_name> `
    -Name <app_service_plan_name> `
    -Location <region_name> `
    -Tier "PremiumV2" `
    -WorkerSize "Small"

更多资源More resources

Azure 中纵向扩展应用Scale up an app in Azure
手动或自动缩放实例计数Scale instance count manually or automatically