具有天蓝色功能的 Alexa 超时

Alexa timeout with azure functions

我有一个 azure 函数正在处理对 Alexa 技能的请求,但由于 azure 函数在 10 秒内没有响应(需要 alexa 技能),我经常会超时:

The requested application took too long to respond

Request Identifier: amzn1.echo-api-request.xxxxx.xxx Application must respond within 10 seconds of the request being sent.

我猜 azure 函数应用程序在不活动后被拆除以节省类似于 azure 网站的资源。

Azure 函数应用 运行 在 消费计划 下,我似乎找不到让它 始终开启的选项 喜欢天蓝色的网站。

我能想到的唯一其他选择是在函数应用程序中创建一个函数来 ping 以保持 azure 函数处于活动状态。它看起来有点老套,所以我想知道是否有更好的方法让 azure 函数应用程序保持活动状态?

您是正确的,因为这是消费计划的设计。如果应用程序上的 all 功能在给定时间内未收到处理请求,则实例将为 'torn down',您将不得不 'warm up'接受的下一个请求。

  • 您可以按照您的建议,'ping' 一个函数来保持它。执行此操作的最佳方法可能是使用基于计时器的触发器将新功能部署到同一应用程序,只需 returns 即可。请注意,这可能会导致更多 'cost',因为您用完了执行时间,尽管非常小。

Preventing to change to cold-start mode is quite easy. Just add a time trigger function within the same function app which executes every 5 minutes. But be aware that this may cause additional costs if your free execution credit is exceeded.

Cold Start and Warm Start on Consumption Plan

  • 或者,您可以使用具有 Always On 功能的应用服务计划,但是,您可能需要权衡此方法的 cost/benefits 与选项 1

If you run on an App Service plan, you should enable the Always On setting so that your function app runs correctly. On an App Service plan, the functions runtime will go idle after a few minutes of inactivity, so only HTTP triggers will "wake up" your functions. This is similar to how WebJobs must have Always On enabled. Always On is available only on an App Service plan. On a Consumption plan, the platform activates function apps automatically.

Always On