gpt4 book ai didi

azure - Alexa 与 azure 函数超时

转载 作者:行者123 更新时间:2023-12-02 07:48:48 24 4
gpt4 key购买 nike

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

The requested application took too long to respond

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

我猜 azure 功能应用程序在不活动后会被拆除,以节省与 azure 网站类似的资源。

azure 函数应用程序在消费计划下运行,但我似乎找不到像 azure 网站那样始终打开的选项。

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

最佳答案

您是正确的,这是消费计划的设计。如果应用程序上的所有功能在给定时间内未收到处理请求,则实例将被“拆除”,您必须为下一个请求“预热”已接受。

  • 您可以按照您的建议,“ping”一个函数来保持它。做到这一点的最佳方法可能是使用基于计时器的触发器将新功能部署到同一应用程序,该触发器会立即返回。请注意,这可能会产生更多“成本”,因为您正在耗尽执行时间,尽管成本非常小。

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

  • 或者,您可以选择具有“始终在线”功能的应用服务计划,但是,您可能需要权衡此方法与选项 1 的成本/ yield

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

关于azure - Alexa 与 azure 函数超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46129727/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com