Azure 应用服务计划:功能与应用服务?

Azure App Service Plan: Function vs App Service?

在应用服务计划中托管 Azure 函数时,与使用与同一应用服务计划关联的应用服务(编辑:restful API)相比,是否存在任何显着差异?我认为唯一的区别是该函数提供了额外的开箱即用触发器。我遗漏的任何差异会导致偏爱其中一个吗?

我还想确认,如果未在应用服务计划中配置缩放,那么在应用服务计划中托管 Azure Functions 实际上会限制可伸缩性。据我了解,当使用 Consumption 或 Premium 托管时,Functions 会根据需要自动扩展,无需额外配置。

主要区别在于支付方式。

  • 您为每次执行支付的 Azure Functions 消耗计划
  • 您为每分钟分配的硬件付费的应用服务中的 Azure Functions(专用计划)。

当您使用应用服务计划时,您还可以控制 运行 在哪个 VNET 中运行。您可能有使这一点变得重要的安全要求。

你是对的,如果你 运行 在未配置为可缩放的应用程序服务中,那么 trough put 将受到分配的硬件的限制。

详情见:https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale

When hosting an Azure Function in an App Service Plan, are there any significant differences compared with using an App Service associated with the same App Service Plan? I assume the only difference is that the Function offers additional out of the box triggers. Any differences I'm missing that would lead to preferring one over the other?

嗯,Azure 函数与应用服务不同。一个 Azure 函数是 triggered by an external event or a timer. It then executes the code of the function. When hosted on a consumption plan this execution is allowed to run for 5 or 10 minutes max。当您需要更长的执行时间时,您需要 运行 应用服务计划。

应用服务可以托管您创建的任何应用。就像一个网站(运行 持续运行并且在它开始做某事之前不需要被触发)或者一个 api 例如。

I'd also like to confirm that hosting Azure Functions in an App Service Plan can actually limit scalability if scaling is not configured on the App Service Plan. As I understand it, Functions automatically scale as needed when using Consumption or Premium hosting without additional configuration.

正确,当在应用服务计划中托管 Azure Functions 时,您有责任确保扩展应用服务以允许函数在负载下良好执行。这就是消费计划旨在处理此问题的原因,以便开发人员可以专注于功能,而无需担心基础架构。

因此,对于集成场景,天蓝色函数非常适合。对于网站,应用服务可能是最佳解决方案。

解决您的评论:

I should have mentioned that this question was in the context of hosting a restful API and not a UI application. In this scenario, I'm not seeing much difference between a Function and App Service, but please correct me if I'm missing something

有几件事:首先,有一个甜蜜点。如果流量足够大,基于 azure function 的消费计划可能比拥有专门的应用程序服务计划成本更高。这当然取决于很多因素(CPU 使用情况、请求持续时间等)。此外,您将无法使用开箱即用的 Asp.Net 核心中间件之类的东西。 最后,我认为,如果您的 api 变得足够大,管理单个 asp.net 核心解决方案可能比管理许多具有小功能的 azure 功能或一个具有许多功能的 azure 功能项目更容易和很多功能,但是嘿,这只是我的意见(老实说我还没有真正处理过)

需要考虑的一些资源: