Azure Functions 消耗计划托管Azure Functions Consumption plan hosting

使用消耗计划时,会根据传入事件数自动添加和删除 Azure Functions 主机实例。When you're using the Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events. 消耗计划是 Azure Functions 的完全无服务器托管选项。The Consumption plan is the fully serverless hosting option for Azure Functions.

优点Benefits

消耗计划会自动缩放,即使在高负载时段也是如此。The Consumption plan scales automatically, even during periods of high load. 如果在消耗计划中运行函数,仅当函数运行时,计算资源才会产生费用。When running functions in a Consumption plan, you're charged for compute resources only when your functions are running. 在消耗计划中,函数执行在可配置的时间段后超时。On a Consumption plan, a function execution times out after a configurable period of time.

有关消耗计划与其他计划和托管类型的比较,请参阅函数缩放和托管选项For a comparison of the Consumption plan against the other plan and hosting types, see function scale and hosting options.

计费Billing

账单将基于执行数量、执行时间和所用内存。Billing is based on number of executions, execution time, and memory used. 使用情况将基于函数应用内的所有函数聚合生成。Usage is aggregated across all functions within a function app. 有关详细信息,请参阅 Azure Functions 定价页For more information, see the Azure Functions pricing page.

若要详细了解在消耗计划中运行时如何估算成本,请参阅了解消耗计划成本To learn more about how to estimate costs when running in a Consumption plan, see Understanding Consumption plan costs.

创建消耗计划函数应用Create a Consumption plan function app

在 Azure 门户中创建函数应用时,消耗计划为默认设置。When you create a function app in the Azure portal, the Consumption plan is the default. 使用 API 创建函数应用时,不必像使用高级计划和专用计划那样首先创建应用服务计划。When using APIs to create you function app, you don't have to first create an App Service plan as you do with Premium and Dedicated plans.

使用以下链接了解如何在消耗计划中以编程方式或通过 Azure 门户创建无服务器函数应用:Use the following links to learn how to create a serverless function app in a Consumption plan, either programmatically or in the Azure portal:

Visual Studio CodeVisual Studio 发布 Functions 项目时,还可以在消耗计划中创建函数应用。You can also create function apps in a Consumption plan when you publish a Functions project from Visual Studio Code or Visual Studio.

同一计划中的多个应用Multiple apps in the same plan

可将同一区域中的函数应用分配到同一个消耗计划。Function apps in the same region can be assigned to the same Consumption plan. 在同一个消耗计划中运行多个应用不会产生负面影响。There's no downside or impact to having multiple apps running in the same Consumption plan. 将多个应用分配到同一个消耗计划不会影响每个应用的复原能力、可伸缩性或可靠性。Assigning multiple apps to the same Consumption plan has no impact on resilience, scalability, or reliability of each app.

后续步骤Next steps