<tfoot id='ilQSB'></tfoot>

      <small id='ilQSB'></small><noframes id='ilQSB'>

      1. <i id='ilQSB'><tr id='ilQSB'><dt id='ilQSB'><q id='ilQSB'><span id='ilQSB'><b id='ilQSB'><form id='ilQSB'><ins id='ilQSB'></ins><ul id='ilQSB'></ul><sub id='ilQSB'></sub></form><legend id='ilQSB'></legend><bdo id='ilQSB'><pre id='ilQSB'><center id='ilQSB'></center></pre></bdo></b><th id='ilQSB'></th></span></q></dt></tr></i><div id='ilQSB'><tfoot id='ilQSB'></tfoot><dl id='ilQSB'><fieldset id='ilQSB'></fieldset></dl></div>

          <bdo id='ilQSB'></bdo><ul id='ilQSB'></ul>

      2. <legend id='ilQSB'><style id='ilQSB'><dir id='ilQSB'><q id='ilQSB'></q></dir></style></legend>

        Azure Functions:计时器触发器和消费计划问题

        时间:2023-10-05

          <small id='2VXTU'></small><noframes id='2VXTU'>

          <tfoot id='2VXTU'></tfoot>

            <tbody id='2VXTU'></tbody>
            • <bdo id='2VXTU'></bdo><ul id='2VXTU'></ul>
            • <legend id='2VXTU'><style id='2VXTU'><dir id='2VXTU'><q id='2VXTU'></q></dir></style></legend>

                <i id='2VXTU'><tr id='2VXTU'><dt id='2VXTU'><q id='2VXTU'><span id='2VXTU'><b id='2VXTU'><form id='2VXTU'><ins id='2VXTU'></ins><ul id='2VXTU'></ul><sub id='2VXTU'></sub></form><legend id='2VXTU'></legend><bdo id='2VXTU'><pre id='2VXTU'><center id='2VXTU'></center></pre></bdo></b><th id='2VXTU'></th></span></q></dt></tr></i><div id='2VXTU'><tfoot id='2VXTU'></tfoot><dl id='2VXTU'><fieldset id='2VXTU'></fieldset></dl></div>

                • 本文介绍了Azure Functions:计时器触发器和消费计划问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的开发环境中,我有一个包含 21 个函数的 Azure Functions,应用计划是消费.

                  In my dev environment, I have an Azure Functions with 21 functions and the app plan is consumption.

                  一些函数有一个计时器触发器,并且在进程结束时每个函数都会发送一封电子邮件.我有 2 种类型的计时器触发器:

                  Some functions have a timer trigger and at the end of the process each function sends an email. I have 2 type of timer trigger:

                  • 每 20 分钟运行一次函数
                  • 在夜间的特定时间运行一次函数

                  每隔 20 分钟,该功能就会按照我的预期进行.太好了.

                  Every 20 minutes the function is doing what I expect. Great.

                  我面临的问题是他们必须在特定时间启动的功能.基本上,直到我打开门户并在 Azure Function 上执行某些操作(例如打开其中一个监视器),它们才会启动.

                  The problem I'm facing is with the function that they have to start at a particular time. Basically, they don't start until I open the portal and do something on the Azure Function (for example open the monitor for one of them).

                  从代码上看,所有带定时器触发的函数都是这样定义的:

                  In the code point of view, all functions with the timer trigger are defined like that:

                  [FunctionName("invoiceMonthlyGeneratorTimer")]
                  public void Run([TimerTrigger("%Timers:GenerateMonthlyInvoices%")] TimerInfo myTimer)
                  {
                      // ..
                  }
                  
                  [FunctionName("invoiceDunningTimer")]
                  public async Task Run([TimerTrigger("%Timers:DunningTimer%")] TimerInfo timer)
                  {
                      // ...
                  }
                  

                  定时器的配置在设置文件中,如:

                  The configuration of the timer is in the settings file like:

                  "Timers": {
                      "DunningTimer": "0 0 4 * * *",
                      "GenerateMonthlyInvoices": "0 0 4 * * *"
                  }
                  

                  一般来说,这种方法在开发环境中运行良好,在生产环境中运行良好.

                  Generally, speaking, this approach was working in dev environment and it is working perfectly in the production environment.

                  因为每个函数都会发送一封电子邮件,我希望每天早上都能在我的收件箱中找到一些电子邮件,但它并没有发生.然后,我打开 Azure 门户以查看日志和监视器.

                  Because each function sends an email, I expect each morning to find in my inbox some emails but it doesn't happen. Then, I open the Azure portal to see the logs and the monitor.

                  在门户中打开 Azure 功能.

                  Open the Azure function in the portal.

                  打开一个函数的监视器

                  瞧,几秒钟后,我开始收到所有服务的电子邮件!在生产环境中,我没有 dev 中的所有功能,因为我想在部署之前进行测试.在 prod 中,这些功能运行良好,并且在正确的时间启动.

                  Voila, after a couple of seconds, I start to receive the email for all services! In the production environment I don't have all the function I have in dev because I want to test before deploying. In prod the functions are working fine and start at the right time.

                  如果我查看 Application Insights,我只能找到打开监视器时的日志.

                  If I look at Application Insights, I can find only the logs for the time I opened the monitor.

                  日志中有一件有趣的事情:

                  There is one interesting thing in the log:

                  触发器详细信息:UnscheduledInvocationReason:IsPastDue,OriginalSchedule:2020-07-24T05:00:00.0000000+00:00

                  Trigger Details: UnscheduledInvocationReason: IsPastDue, OriginalSchedule: 2020-07-24T05:00:00.0000000+00:00

                  显然,在同一个 Azure Functions 中不能有多个计时器触发器.我在 Github 上打开了一个问题,所以如果其他开发人员也面临同样的问题.与 HTTP 触发器类似的东西,看看这个 post.

                  Apparently, you can't have more than a couple of timer triggers in the same Azure Functions. I opened an issue on Github, so if other devs are facing the same. Something similar with HTTP triggers, look this post.

                  推荐答案

                  您的函数应用中的函数太多,它们可能会相互交互.我遇到了类似的问题,在这种情况下,计时器触发器在一个功能应用程序中起作用并且不起作用.但是当我将它们部署到不同的功能应用程序时,它们工作正常.因此您可以尝试将您的第二个函数部署到另一个函数应用.

                  There are too many functions in your function app, they may interact each other. I met similar problem with this, in that case, the timer trigger functions in one function app and did not work. But when i deploy them to different function apps, they work fine. so you can try to deploy your second function to another function app.

                  而且我建议你把这个问题报告给微软,他们可以知道更多关于这个问题的信息,并且可能有更好的解决方案.

                  And I suggest you report this problem to Microsoft, they can know more information about this problem, and may have a better solution.

                  这篇关于Azure Functions:计时器触发器和消费计划问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Azure Functions - 无法从 Azure WebJobs SDK 调用 下一篇:azure 服务总线的 Azure Function App 延迟重试

                  相关文章

                  <tfoot id='71flZ'></tfoot>
                    <legend id='71flZ'><style id='71flZ'><dir id='71flZ'><q id='71flZ'></q></dir></style></legend>

                  1. <small id='71flZ'></small><noframes id='71flZ'>

                    • <bdo id='71flZ'></bdo><ul id='71flZ'></ul>
                      <i id='71flZ'><tr id='71flZ'><dt id='71flZ'><q id='71flZ'><span id='71flZ'><b id='71flZ'><form id='71flZ'><ins id='71flZ'></ins><ul id='71flZ'></ul><sub id='71flZ'></sub></form><legend id='71flZ'></legend><bdo id='71flZ'><pre id='71flZ'><center id='71flZ'></center></pre></bdo></b><th id='71flZ'></th></span></q></dt></tr></i><div id='71flZ'><tfoot id='71flZ'></tfoot><dl id='71flZ'><fieldset id='71flZ'></fieldset></dl></div>