简体   繁体   English

如何为长时间运行的Azure函数创建启动代码?

[英]How do I create startup code for longrunning azure functions?

I plan to create a functions project that is always running, but responds to multiple triggers as per azure functions. 我计划创建一个始终运行的功能项目,但根据天蓝色功能响应多个触发器。

I know this can be done with webjobs, but can it be done with functions? 我知道这可以通过webjobs完成,但是可以通过函数完成吗? If so how do I hook up a startup file as entry point for the longrunning (blocking) background task? 如果是这样,我如何将启动文件作为长时间运行(阻止)后台任务的入口点连接?

The exact point of Azure Functions is that they only run in response to events. Azure Functions的确切之处在于它们仅在响应事件时运行。 If no events occur, they don't run. 如果没有事件发生,则它们不会运行。

Functions are not a good match for always-running background processes. 函数对于始终运行的后台进程不是很好的匹配。

Please note, that Azure functions have a runtime hard limit of 10 minutes: https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale . 请注意,Azure函数的运行时硬限制为10分钟: https : //docs.microsoft.com/zh-cn/azure/azure-functions/functions-scale

That means, you should plan your function to only react to the different events, process it and is then disposed. 这意味着,您应该计划功能以仅对不同事件做出反应,进行处理,然后处置。 Depending on your use case, you should consider other options - maybe you can tell some more about the goal you want to achieve. 根据您的用例,您应该考虑其他选择-也许您可以告诉更多有关您要实现的目标的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM