具有Azure功能的Alexa超时 [英] Alexa timeout with azure functions

查看:87
本文介绍了具有Azure功能的Alexa超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an azure function that is dealing with requests for an Alexa skill, but every so often I get a timeout due to the azure function not responding within 10 seconds (requirement of an alexa skill):


请求的应用程序响应时间太长

The requested application took too long to respond

请求标识符:amzn1.echo-api-request。 xxxxx.xxx
应用程序必须在发送请求后10秒内响应。

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

我猜是azure函数应用程序闲置后被拆除,以节省类似于天蓝色网站的资源。

I'm guessing the azure function app is getting teared down after inactivity to save on resources similar to azure websites.

Azure功能应用程序正在消费计划下运行,我似乎找不到始终启用它的选项。 就像azure网站一样。

The azure function app is running under a Consumption Plan and I can't seem to find an option to have it always on like the azure websites.

我唯一想到的另一种选择是在功能应用内创建一个函数来ping,以保持azure功能的生命。似乎有点黑,所以我想知道是否有更好的方法可以使azure函数应用程序保持活动状态?

The only other option I can think of doing is creating a function within the function app to ping to keep the azure function alive. It just seems a bit hacky so I wondered if there is a better way to keep the azure function app alive?

推荐答案

正确的是,这是根据消费计划设计的。如果应用程序上的所有函数在给定的时间内未收到处理请求,则实例将被拆除,您将必须为下一个请求进行预热。

You are correct in that this is by design of the Consumption plan. If all functions on the Application have not received a request for processing for a given amount of time, the instance will be 'torn down' and you will have to 'warm up' for the next request that is accepted.


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


防止更改为冷启动模式非常容易。只需在每5分钟执行一次的同一功能应用程序中添加时间触发功能。但是请注意,如果超出了免费执行额度,这可能会导致额外的费用。

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.

消费计划的冷启动和热启动


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


如果您运行的是App Service计划,则应启用Always On设置,以使功能应用程序正确运行。根据App Service计划,功能运行时将在闲置几分钟后变为空闲状态,因此只有HTTP触发器会唤醒您的功能。这类似于WebJobs必须启用Always On的方式。
Always On仅在App Service计划中可用。根据消费计划,平台会自动激活功能应用程序。

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.

始终在线

这篇关于具有Azure功能的Alexa超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆