What is the simplest way to run a timer-triggered Azure Function locally once?

后端 未结 7 891
醉话见心
醉话见心 2020-12-13 12:03

I have a few C# Azure Functions that run on a schedule using timer triggers. I\'ve set them up like so, where %TimerSchedule% refers to a cron expression in the

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 12:35

    You could perhaps use the RunOnStartup flag as documented here. It doesn't quite meet your brief regarding it only running once, but it should at least execute it locally once the app has started.

    /// Gets or sets a value indicating whether the function should be invoked
    /// immediately on startup. After the initial startup run, the function will
    /// be run on schedule thereafter.
    

    Example using attribute binding:

    [TimerTrigger("%TimerSchedule%", RunOnStartup = true)]TimerInfo myTimer

提交回复
热议问题