带计时器触发器的Azure函数:UnscheduledInvocationReason [英] Azure Functions with timer trigger: UnscheduledInvocationReason

查看:130
本文介绍了带计时器触发器的Azure函数:UnscheduledInvocationReason的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Azure函数中,我有26个函数,只有7个带有计时器触发器(请参阅我的其他帖子,但这是很老).没有关于此的Microsoft建议.某些功能具有计时器触发器,并且在该过程结束时,每个功能都会发送一封电子邮件.我有2种类型的计时器触发器:

In my Azure Functions I have 26 functions and only 7 with the timer trigger (see my previous post also I saw this other post but it is quite old). There is no recommendation for Microsoft about it. 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分钟执行一次我期望的操作

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

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 * * *"
}

假设我早上没有收到任何电子邮件,我检查了Application Insights,也没有找到与计时器功能相关的任何日志.

Suprised that I didn't receive any email in the morning, I checked Application Insights and didn't find any logs related to the timer fuctions.

然后,我在门户中打开"Azure功能",单击一个功能,然后神奇地收到了电子邮件.在日志中,我发现了如下相同的日志:

Then, I opened in the portal the Azure Functions, clicked on one function and magically, I received the email. In the logs I found same logs like the following:

触发器详细信息:UnscheduledInvocation原因:IsPastDue,原始时间表:2020-07-24T05:00:00.0000000 + 00:00

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

正如一个小伙子在我上一篇文章的评论中所建议的那样,计时器触发功能将发生冲突并且无法启动.似乎很烦人.我还在 Github 上打开了一个问题.

As a lad suggests in the comment of my previous post, timer trigger functions are going to have a conflict and don't start. It seems quite annoying. I also opened an issue on Github.

Azure功能中是否存在有关计时器触发功能的准则?有人遇到过与我相同的问题吗?

Is there any kind of guidelines for timer trigger functions in Azure Functions? Has someone else faced the same issue as me?

推荐答案

对于此问题,我认为它可能是由一个功能应用程序中的多个功能引起的,正如您之前提到的那样.我在一个功能应用程序中遇到了http触发功能和计时器触发功能的类似问题.该代码非常简单(我确认代码中没有错误),但是无法及时触发计时器触发功能.

For this problem, I think it may caused by multiple functions in one function app as your previous post mentioned. I met a similar problem with http trigger function and timer trigger function in one function app. The code is very simple(I confirm that there are no errors in the code), but the timer trigger function can't be triggered on time.

此处是我遇到类似问题的帖子.解决方法是在不同的功能应用程序中创建功能.对于您的问题,我认为您可以如上所述在不同的功能应用程序中创建功能,也可以按照以下

Here is the post of the similar problem I met. The workaround is create the functions in different function apps. For your problem, I think you can just create the functions in different function apps as I mentioned above or you can raise a support ticket on azure portal by following the steps on this page. The azure support team will help you on it, because they can view more log details of your function. I think it's hard to get the help you want on stack overflow community.

这篇关于带计时器触发器的Azure函数:UnscheduledInvocationReason的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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