Is there any way to synchronously 'invoke' a timer triggered function to execute within the runtime environment? I would like to run an automated integration test for my function with hourly schedule, but waiting up to an hour in my test is not practical.
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@MrGlenThomas Thanks for the question. We are currently investigating and will update you shortly.
@wesmc7777 is this something you might be able to provide some information on? Else @MrGlenThomas I would suggest you ask this question in the forums as it is not directly pointing out problems with this specific documentation
https://social.msdn.microsoft.com/Forums/en-US/home?forum=AzureFunctions
I don't think you can manually invoke any function outside of firing the trigger. The best approach might be to use an HTTP trigger to kick off the integration test. However, I'm a little out of touch in this area since, I've not been involved in a while. @ggailey777 or @tdykstra could likely provide a more definite answer here.
If it is possible to add an http trigger to a timer triggered function to invoke it that might be a solution, but I'm not sure how this might be achieved. Would it require a second function that calls the run method of the timer triggered function? @MicahMcKittrick-MSFT The problem with this documentation is that it does not provide any explanation on testing timer triggered functions.
Thanks @MrGlenThomas and @wesmc7777. We can see what @ggailey777 or @tdykstra have to say but for sure something that might be useful to include in this document for others to reference to.
@MrGlenThomas This is a recurring issue and one solution I've seen recommended is here: https://stackoverflow.com/questions/44569926/time-triggered-azure-function-to-trigger-immediately-after-deploy?noredirect=1&lq=1
Would this (two functions with different triggers but shared code) meet your needs?
@MrGlenThomas just checking in to see if you had a response for @tdykstra
@MrGlenThomas I will close this out for now. When ready please come back to reopen and we can continue.
@MrGlenThomas See also this documentation on using the admin API to trigger a function by using an HTTP request: https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#non-http-triggered-functions
@MrGlenThomas See also this documentation on using the admin API to trigger a function by using an HTTP request: https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#non-http-triggered-functions
I have tried executing http://localhost:7071/admin/functions/{nameOfFunction} as suggested by https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#non-http-triggered-functions from Postman against a Timer Triggered Function that is being run locally by func cli. My function is a bare-bone one that suppose to just output a text into a Console.
After I have sent GET: I've got '405 Method Not Allowed'
After I have sent POST without any headers: I've got '400 Bad Request'
In neither case my TimerTrigger function was triggered.
@RusmanCool
For some reason you will also have to provide a body with an input property.
The following worked for me:
POST: http://localhost:7071/admin/functions/{functionName}
{
"input": ""
}
Trigger Details: UnscheduledInvocationReason: IsPastDue, OriginalSchedule:
At startup I am getting this message when I start the debugger. is there any way to clear the cron scheduled tasks before I launch the debugger? I can set a breakpoint at the function start and skip the auto-triggered invocation but I have to remember to do that. Is there any way to configure via hosts.json to disregard missed invocations? That might be a usable solution.
Most helpful comment
@RusmanCool
For some reason you will also have to provide a body with an input property.
The following worked for me:
POST: http://localhost:7071/admin/functions/{functionName}