7

My task runs once a day when deployed. For development currently I just changed the CRON to "every minute" and wait for that minute to hit in order for the function to be triggered for me to do the debugging. Is there a way such that I can leave my timer code to stay as "Every day" but still be able to kick it off manually.

In Azure I can just go to the function resource and click "Run" that will start it regardless of the timer. I am looking for something similar on my dev.

scorpion5211
  • 1,020
  • 2
  • 13
  • 33
  • 3
    Does this answer your question? [What is the simplest way to run a timer-triggered Azure Function locally once?](https://stackoverflow.com/questions/46556621/what-is-the-simplest-way-to-run-a-timer-triggered-azure-function-locally-once) – IronSean Jul 14 '21 at 22:41

3 Answers3

11

You are probably looking for this on the Timer Trigger attribute,

[TimerTrigger("", RunOnStartup = true)]TimerInfo timer

That should kick it off on startup.

tokyo0709
  • 1,897
  • 4
  • 28
  • 49
1

It doesn't look like there is a direct solution available to manually (or even through and http request) trigger a time based Azure function.

Possible Workaround

Have a second http triggered function that has the same logic/code. You can use this 2nd function for testing on demand basis.

Please see the discussion in these 2 threads, it's very relevant to you -

Any method for testing timer trigger function

Time triggered azure function to trigger immediately after deploy

Rohit Saigal
  • 9,317
  • 2
  • 20
  • 32
  • It's seems now there is a HTTP solution to execute a timer function, both [locally](https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local#non-http-triggered-functions), as well as [in the Azure cloud](https://learn.microsoft.com/mt-mt/Azure/azure-functions/functions-manually-run-non-http) – Slawomir Brzezinski Jan 09 '19 at 15:21
0

As @neo99 mentioned, simple answer is it is not possible just out of the box. The reason is input parameters for Run method of Trigger function are different for different type of triggers.

For e.g. you are looking to manually trigger(HttpTrigger) a TimerTrigger

Timer Trigger:

[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)

Http Trigger:

[FunctionName("HttpTriggerCSharp")]
public static async Task<HttpResponseMessage> Run(
    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, 
    TraceWriter log)