Alexa timeout with azure functions

自闭症网瘾萝莉.ら 提交于 2019-12-24 20:03:05

问题


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

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

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

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.

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?


回答1:


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.

  • You can, as you suggested, 'ping' a function to keep it up. The best way to do this is probably to deploy a new function to the same application with a timer based trigger that simply returns straight away. Please note this may incur more 'cost' as you are using up execution time, albeit very small.

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

  • Alternatively, you can go with an App Service Plan which does have the Always On feature, however, you may need to weigh up the cost/benefits of this approach vs option 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



来源:https://stackoverflow.com/questions/46129727/alexa-timeout-with-azure-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!