gpt4 book ai didi

Azure 函数(时间触发器)仅在打开 Azure 门户时触发

转载 作者:行者123 更新时间:2023-12-03 05:30:30 26 4
gpt4 key购买 nike

我创建了一个时间触发器 Azure 函数,该函数以 2 小时的间隔触发。每次我打开 Azure 门户时,它都会被触发,之后就不会被触发。

我在Google中搜索了一些链接,但没有得到任何合适的解决方案。谁能帮帮我吗?

[FunctionName("MailFailureFucntion")]
public static void Run([TimerTrigger("*/30 * * * *")] TimerInfo myTimer, ILogger log)
{

// my code - connecting SQL and send mail

}

最初我尝试使用 0 */2 * * * - 2 小时间隔。然后我尝试了 */30 * * * *

最佳答案

这是 Azure Function Cron Expresion 的备忘单

https://arminreiter.com/2017/02/azure-functions-time-trigger-cron-cheat-sheet/

在您的情况下,代码可能如下所示(每 2 小时运行一次)

public static void Run([TimerTrigger("0 0 */2 * * *")]TimerInfo myTimer, ILogger log)

我还建议检查 runOnStartup 并确保将其设置为 false

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=python#configuration

关于Azure 函数(时间触发器)仅在打开 Azure 门户时触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65917602/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com