您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

Azure Functions 高级计划 (预览)Azure Functions Premium plan (preview)

Azure Functions 高级计划是函数应用的托管选项。The Azure Functions Premium plan is a hosting option for function apps. 高级计划提供 VNet 连接、无冷启动和高级硬件等功能。The Premium plan provides features like VNet connectivity, no cold start, and premium hardware. 可以将多个函数应用部署到相同的高级计划, 该计划允许配置计算实例大小、基本计划大小和最大计划大小。Multiple function apps can be deployed to the same Premium plan, and the plan allows you to configure compute instance size, base plan size, and maximum plan size. 有关高级计划以及其他计划和托管类型的比较, 请参阅函数缩放和宿主选项For a comparison of the Premium plan and other plan and hosting types, see function scale and hosting options.

创建高级计划Create a Premium plan

  1. 转到 Azure 门户Go to the Azure portal.

  2. 选择左侧的 " + 创建资源", 然后选择 "函数应用"。Select + Create a resource on the left hand side, then choose Function app.

  3. 对于 "托管计划", 请选择 "应用服务计划", 然后选择 "应用服务计划/位置"。For Hosting plan, choose App Service plan, then select App Service plan/Location.

    创建函数应用

  4. 选择 "新建", 键入应用服务计划名称, 选择附近或附近的区域中的某个位置或函数访问的其他服务, 然后选择 "定价层"。Select Create new, type an App Service plan name, choose a Location in a region near you or near other services your functions access, and then select Pricing tier.

    创建应用服务计划

  5. 选择EP1 (弹性高级) 计划, 并选择 "应用"。Choose the EP1 (elastic Premium) plan, then select Apply.

    选择高级计划

  6. 选择 "确定" 以创建计划, 并使用图像下的表中指定的其余 function app 设置。Select OK to create the plan, then use the remaining function app settings as specified in the table below the image.

    已完成应用服务计划

    设置Setting 建议的值Suggested value 描述Description
    应用名称App name 全局唯一名称Globally unique name 用于标识新 Function App 的名称。Name that identifies your new function app. 有效的字符是 a-z0-9-Valid characters are a-z, 0-9, and -.
    订阅Subscription 你的订阅Your subscription 要在其下创建此新函数应用的订阅。The subscription under which this new function app is created.
    资源组Resource Group myResourceGroupmyResourceGroup 要在其中创建 Function App 的新资源组的名称。Name for the new resource group in which to create your function app. 你还可以使用建议的值。You can also use the suggested value.
    OSOS 首选操作系统Preferred OS 高级计划支持 Linux 和 Windows。Both Linux and Windows are supported on the Premium plan.
    运行时堆栈Runtime stack 首选语言Preferred language 选择支持你喜欢的函数编程语言的运行时。Choose a runtime that supports your favorite function programming language. 对于 C# 和 F# 函数,选择 .NETChoose .NET for C# and F# functions. 仅显示所选OS上支持的语言。Only languages supported on your chosen OS are displayed.
    存储Storage 全局唯一名称Globally unique name 创建函数应用使用的存储帐户。Create a storage account used by your function app. 存储帐户名称必须为 3 到 24 个字符,并且只能包含数字和小写字母。Storage account names must be between 3 and 24 characters in length and may contain numbers and lowercase letters only. 也可使用现有帐户,但该帐户必须符合存储帐户要求You can also use an existing account, which must meets the storage account requirements.
    Application InsightsApplication Insights 默认Default 在最近的受支持的区域中,创建一个具有相同应用名称的 Application Insights 资源。Creates an Application Insights resource of the same App name in the nearest supported region. 展开此设置即可更改“新建资源名称”,或者在 Azure 地理位置中选择另一个需要在其中存储数据的位置By expanding this setting, you can change the New resource name or choose a different Location in an Azure geography where you want to store your data.
  7. 验证设置后, 选择 "创建"。After your settings are validated, select Create.

  8. 选择门户右上角的“通知”图标,留意是否显示“部署成功”消息。Select the Notification icon in the upper-right corner of the portal and watch for the Deployment succeeded message.

    定义新的函数应用设置

  9. 选择“转到资源”,查看新的函数应用。Select Go to resource to view your new function app. 还可选择“固定到仪表板”。You can also select Pin to dashboard. 固定可以更轻松地从仪表板返回此函数应用资源。Pinning makes it easier to return to this function app resource from your dashboard.

你还可以在 Azure CLI 中使用az functionapp plan create创建高级计划。You can also create a Premium plan using az functionapp plan create in the Azure CLI. 以下示例创建一个_弹性高级版 1_层计划:The following example creates an Elastic Premium 1 tier plan:

az functionapp plan create --resource-group <RESOURCE_GROUP> --name <PLAN_NAME> \
--location <REGION> --sku EP1

在此示例中, <RESOURCE_GROUP>将替换为资源组<PLAN_NAME> , 并将替换为在资源组中唯一的计划的名称。In this example, replace <RESOURCE_GROUP> with your resource group and <PLAN_NAME> with a name for your plan that is unique in the resource group. 指定支持<REGION>的。Specify a supported <REGION>. 若要创建支持 Linux 的高级计划, 请包括--is-linux选项。To create a Premium plan that supports Linux, include the --is-linux option.

创建计划后, 可以使用az functionapp create创建 function app。With the plan created, you can use az functionapp create to create your function app. 在门户中, 计划和应用都同时创建。In the portal, both the plan and the app are created at the same time.

功能Features

以下功能可用于部署到高级计划的函数应用。The following features are available to function apps deployed to a Premium plan.

准备好实例Pre-warmed instances

如果在消耗计划中今天没有发生事件和执行, 则应用可能会缩小到零实例。If no events and executions occur today in the Consumption plan, your app may scale down to zero instances. 当出现新事件时, 需要使用在其上运行的应用程序来专用化新的实例。When new events come in, a new instance needs to be specialized with your app running on it. 专用化新实例可能需要一些时间, 具体取决于应用程序。Specializing new instances may take some time depending on the app. 第一次调用的额外延迟通常称为应用冷启动。This additional latency on the first call is often called app cold start.

在高级计划中, 你可以将应用预先准备好指定数量的实例, 最小计划大小。In the Premium plan, you can have your app pre-warmed on a specified number of instances, up to your minimum plan size. 使用准备好实例, 还可以在高负载之前预缩放应用。Pre-warmed instances also let you pre-scale an app before high load. 在应用程序扩展时, 它首先扩展到准备好实例。As the app scales out, it first scales into the pre-warmed instances. 其他实例将继续为下一个缩放操作做好缓冲并使其立即预热。Additional instances continue to buffer out and warm immediately in preparation for the next scale operation. 通过使用准备好实例的缓冲区, 可以有效地避免冷启动延迟。By having a buffer of pre-warmed instances, you can effectively avoid cold start latencies. 准备好实例是高级计划的一项功能, 需要在计划处于活动状态时至少保持一个实例处于运行状态且可用。Pre-warmed instances is a feature of the Premium plan, and you need to keep at least one instance running and available at all times the plan is active.

您可以通过选择Function App, 转到 "平台功能" 选项卡, 然后选择 " Scale Out " 选项, 在 Azure 门户中配置准备好实例的数目。You can configure the number of pre-warmed instances in the Azure portal by selected your Function App, going to the Platform Features tab, and selecting the Scale Out options. 在函数应用编辑窗口中, 准备好实例特定于该应用, 但最小和最大实例适用于你的整个计划。In the function app edit window, pre-warmed instances is specific to that app, but the minimum and maximum instances apply to your entire plan.

弹性缩放设置

你还可以使用 Azure CLI 配置应用的预准备好实例You can also configure pre-warmed instances for an app with the Azure CLI

az resource update -g <resource_group> -n <function_app_name>/config/web --set properties.preWarmedInstanceCount=<desired_prewarmed_count> --resource-type Microsoft.Web/sites

专用网络连接Private network connectivity

部署到高级计划的 Azure Functions 将利用适用于 web 应用的新 VNet 集成Azure Functions deployed to a Premium plan takes advantage of new VNet integration for web apps. 配置后, 你的应用可以与 VNet 中的资源通信, 或通过服务终结点进行保护。When configured, your app can communicate with resources within your VNet or secured via service endpoints. 应用上也提供了 IP 限制, 以限制传入流量。IP restrictions are also available on the app to restrict incoming traffic.

在高级计划中向函数应用分配子网时, 需要一个子网, 其中每个潜在实例都有足够的 IP 地址。When assigning a subnet to your function app in a Premium plan, you need a subnet with enough IP addresses for each potential instance. 尽管在预览期间最大实例数可能有所不同, 但我们需要至少有100个可用地址的 IP 块。Though the maximum number of instances may vary during the preview, we require an IP block with at least 100 available addresses.

有关详细信息, 请参阅将 function app 与 VNet 集成Fore more information, see integrate your function app with a VNet.

快速弹性缩放Rapid elastic scale

使用与消耗计划相同的快速缩放逻辑, 为你的应用自动添加其他计算实例。Additional compute instances are automatically added for your app using the same rapid scaling logic as the Consumption plan. 若要详细了解缩放的工作方式, 请参阅函数缩放和宿主To learn more about how scaling works, see Function scale and hosting.

无限运行持续时间Unbounded run duration

对于单个执行, 消耗计划中的 Azure Functions 限制为10分钟。Azure Functions in a Consumption plan are limited to 10 minutes for a single execution. 在高级计划中, 运行持续时间默认为30分钟, 以防止执行失控。In the Premium plan, the run duration defaults to 30 minutes to prevent runaway executions. 不过, 你可以修改 host json 配置, 使其不受高级计划应用的限制。However, you can modify the host.json configuration to make this unbounded for Premium plan apps.

在预览版中, 你的持续时间不一定超过12分钟, 并且如果你的应用未缩放到超出其最小辅助角色计数, 则最有可能运行30分钟以上。In preview, your duration is not guaranteed past 12 minutes and will have the best chance of running beyond 30 minutes if your app is not scaled beyond its minimum worker count.

计划和 SKU 设置Plan and SKU settings

创建计划时, 需要配置两个设置: 实例的最小数目 (或计划大小) 和最大猝发限制。When you create the plan, you configure two settings: the minimum number of instances (or plan size) and the maximum burst limit. 高级计划的最小实例数为 1, 预览期间的最大突发值为20。The minimum instances for a Premium plan is 1, and the maximum burst during the preview is 20. 最小实例保留并始终运行。Minimum instances are reserved and always running.

重要

对于在最小实例计数中分配的每个实例, 无论函数是否正在执行, 都将向你收费。You are charged for each instance allocated in the minimum instance count regardless if functions are executing or not.

如果你的应用程序需要的实例超出了你的计划大小, 则它可以继续横向扩展, 直到实例数达到最大猝发限制。If your app requires instances beyond your plan size, it can continue to scale out until the number of instances hits the maximum burst limit. 仅当计划规模正在运行且为你租借时, 才会向你收费。You are billed for instances beyond your plan size only while they are running and rented to you. 我们将尽最大努力将应用扩展到其定义的最大限制, 而最小计划实例可确保适用于你的应用。We will make a best effort at scaling your app out to its defined maximum limit, whereas the minimum plan instances are guaranteed for your app.

您可以通过选择计划中的Scale Out选项或部署到该计划的函数应用 (在 "平台功能" 下), 在 Azure 门户中配置计划大小和最大值。You can configure the plan size and maximums in the Azure portal by selected the Scale Out options in the plan or a function app deployed to that plan (under Platform Features).

还可以增加 Azure CLI 的最大猝发限制:You can also increase the maximum burst limit from the Azure CLI:

az resource update -g <resource_group> -n <premium_plan_name> --set properties.maximumElasticWorkerCount=<desired_max_burst> --resource-type Microsoft.Web/serverfarms 

可用实例 SkuAvailable instance SKUs

创建或缩放计划时, 可以在三种实例大小之间进行选择。When creating or scaling your plan, you can choose between three instance sizes. 将按照内核总数和每秒使用的内存数计费。You will be billed for the total number of cores and memory consumed per second. 应用可根据需要自动向外扩展到多个实例。Your app can automatically scale out to multiple instances as needed.

SKUSKU 内核Cores 内存Memory 存储Storage
EP1EP1 11 3.5 GB3.5GB 250GB250GB
EP2EP2 22 7GB7GB 250GB250GB
EP3EP3 44 14 GB14GB 250GB250GB

RegionsRegions

下面是每个操作系统的公共预览版当前支持的区域。Below are the currently supported regions for the public preview for each OS.

地区Region WindowsWindows LinuxLinux
澳大利亚东部Australia East
澳大利亚东南部Australia Southeast
加拿大中部Canada Central
美国中部Central US
东亚East Asia
East USEast US
美国东部 2East US 2
法国中部France Central
日本东部Japan East
日本西部Japan West
韩国中部Korea Central
美国中北部North Central US
北欧North Europe
美国中南部South Central US
印度南部South India
东南亚Southeast Asia
英国西部UK West
西欧West Europe
印度西部West India
美国西部West US

已知问题Known Issues

可以跟踪GitHub 上公共预览版的已知问题状态。You can track the status of known issues of the public preview on GitHub.

后续步骤Next steps