Azure Function计时器运行两次,并且在我登录到Azure门户时 [英] Azure Function timer is running twice and when I log onto the Azure portal

查看:163
本文介绍了Azure Function计时器运行两次,并且在我登录到Azure门户时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Azure中有一个定时功能应用程序,计划于每天22:00运行.但是,它似乎每天都在21:59和22:00运行.当我登录到Azure门户检查日志时,它似乎还随机运行.

I have a Timed Function App in Azure that is scheduled to run at 22:00 daily. However, it appears to run at 21:59 and also at 22:00, consistently every day. It also appears to run at random when I am logged into the Azure portal checking the logs.

这是我得到的重复条目的时间戳的一个示例:

Here's an example of the timestamps of the duplicate entries I am getting:

我已经在网上搜索了,但找不到有效的解决方案.

I have searched the web but have found no working solution.

这是应用程序的签名,大约需要20秒钟才能完成:

Here's the signature of the app, which takes about 20s to complete:

[FunctionName("Function1")]
public static void Run([TimerTrigger("0 0 22 * * *", RunOnStartup = false)]TimerInfo myTimer, TraceWriter log)
{
   // My code
}

这是我的local.settings.json:

And here's my local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX",
    "AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX",
    "type": "timerTrigger",
    "schedule": "0 0 22 * * *",
    "useMonitor": false,
    "SQLConn": "Server=tcp:XXX.database.windows.net,1433;Initial Catalog=XXX;Persist Security Info=False;User ID=XXX;Password=XXX;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
  },
  "disabled": false
}

有人可以帮我吗?

此外,Azure功能中的监视器"部分也没有显示异常.

Also, the "Monitor" section in Azure's functions show nothing unusual.

推荐答案

我查看了您的函数应用程序的内部日志(感谢共享名称!),我看到了以下内容:

I took a look at our internal logs for your function app (thanks for sharing the name!), and I see the following:

2018-03-02 14:43:50.4977179: Function 'DemoAzureFunction.Function1.Run' is configured to run on startup. Executing now.
2018-03-02 14:44:01.7856855: Function 'DemoAzureFunction.Function1.Run' updated status: Last='2018-03-02T14:43:48.6103583+00:00', Next='2018-03-02T22:00:00.0000000+00:00', LastUpdated='3/2/2018 2:43:48 PM'

所以在我看来,您的功能配置中至少有RunOnStartup = true个.通过这种方式配置后,访问门户网站可以触发计时器立即运行(与配置的时间表分开),因为门户网站的交互将唤醒您的功能应用程序.

So it looks to me that at one point you had RunOnStartup = true in your function configuration. When configured this way, accessing the portal can trigger the timer to run immediately (separate from the configured schedule) since the portal interaction will wake up your function app.

这篇关于Azure Function计时器运行两次,并且在我登录到Azure门户时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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