Azure functions with C#
provides a way to run the TimerTrigger
at starts up time with RunOnStartup
parameter as follows.
[FunctionName("TimeTrigger_Startup")]
public async Task Migrations([TimerTrigger("0 */4 * * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger logger) {
// Startup script
}
But, there is no option for Java TimerTrigger
functions.
@FunctionName("Warmup")
public void run(@TimerTrigger(name = "warmupTrigger", schedule = "0 */4 * * * *") String timerInfo, ExecutionContext context) {
// Startup script
}
There is no equivalent variable for RunOnStartup
in annotation @TimerTrigger
to start at start time. Is there any work around to execute the method in Azure Java function on startup?
Currently this not possible using annotations. Current work-around is to add these properties in the generated function.json
file as described here. There is an open PR which will address this issue.