You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Function TimeTrigger重复触发问题求助

Azure Function TimerTrigger 反复触发问题

问题现象

我有一个名为POEditorTranslations的Azure Function,TimerTrigger配置的Cron表达式为:

* */10 * * * *

最初它是异步函数public static async Task POEditorTranslations...,调用多个外部API并等待响应时,发现它未按10分钟间隔执行,而是反复触发。改成仅输出日志的基础同步函数后,问题仍然存在!

函数代码

[FunctionName("POEditorTranslations")]
public static void POEditorTranslations([TimerTrigger("%POEditorSchedule%")] TimerInfo myTimer, ILogger log, Microsoft.Azure.WebJobs.ExecutionContext context)
{
    IConfigurationRoot config = new ConfigurationBuilder()
                .SetBasePath(context.FunctionAppDirectory)
                .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .Build();

    log.LogInformation($"POEditorTranslations TESTING function executed at: {DateTime.Now}, POEditorSchedule: {config.GetValue<string>("POEditorSchedule")}");

}

关键细节

  • 本地Visual Studio运行正常,本地存在local.settings.json文件,但Azure环境中无该文件。
  • 日志显示配置项POEditorSchedule的值正确,但触发间隔仅约1秒,日志片段如下:
2023-08-24T08:30:00Z   [Verbose]   Timer for 'POEditorTranslations' started with interval '00:00:00.8937384'.
2023-08-24T08:30:01Z   [Information]   Executing 'POEditorTranslations' (Reason='Timer fired at 2023-08-24T08:30:00.9949394+00:00', Id=7a0544f4-4a28-44a4-a379-2a441edb0d82)
2023-08-24T08:30:01Z   [Information]   POEditorTranslations TESTING function executed at: 8/24/2023 8:30:00 AM, POEditorSchedule: * */10 * * * *
2023-08-24T08:30:01Z   [Information]   Executed 'POEditorTranslations' (Succeeded, Id=7a0544f4-4a28-44a4-a379-2a441edb0d82, Duration=1ms)
2023-08-24T08:30:01Z   [Verbose]   Function 'POEditorTranslations' updated status: Last='2023-08-24T08:30:01.0000000+00:00', Next='2023-08-24T08:30:02.0000000+00:00', LastUpdated='2023-08-24T08:30:01.0000000+00:00'

更新内容

有人建议在Azure门户使用环境变量替代配置,但找不到对应的菜单:
Azure门户配置菜单截图

内容的提问来源于stack exchange,提问作者Persyl

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 10:22:07