I have published a Timer Trigger Azure Function to my Azure account. I configured it to run twice a day but I would like to be able to run on demand. Surprisingly it is not a easy to find feature, neither easy to find online for help.
4 Answers
There is a URL you can use to trigger non HTTP triggered functions.
https://[hostname]/admin/functions/[name_of_your_function]
You POST to this URL with the function apps _master key in the x-functions-key header. You can read it in detail here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http

- 770
- 10
- 27
-
1does not work for me, I got 404 response code. – Zhli Sep 08 '22 at 13:53
If you want to run it locally you have to POST a request to http://localhost:<port>/admin/functions/<functionName>
with an empty json payload e.g.
POST /admin/functions/MyTimerFunction HTTP/1.1
Host: localhost:7071
Content-Type: application/json
Content-Length: 2
{}
I've yet to get it to work on an Azure-deployed Function, though.

- 1,228
- 14
- 27
Azure Function Timer Trigger - I configured it to run twice a day but I would like to be able to run on demand.
I believe your ask is - Is it possible to run the Timer Triggered Azure Function on demand/request.
Scenario 1:
AFAIK, that is not possible to run on-demand/request the Azure Timer Triggered Function with the same function but we can use an HTTP Triggered function as the 2nd function which uses the same logic as the timer function that runs on a schedule - is the best approach for testing on-demand basis.
Please check the example described here.
Scenario 2:
Suppose the scenario is running/testing the Azure Function Timer Trigger after every deployment but the CRON is configured twice in a day or other, then the runOnStartup
setting is used as documented here and in MSFT docs, which triggers the function when the runtime starts but won't cause the runtime to start as a result of a deployment.
You could use 2 different functions in the same function app, one function is the time triggered one and the other is an Http triggered that you can call on demand. "As part of your solution, you may develop and publish multiple functions. These functions are often combined into a single function app"
Put the code you want to run in some shared "place" like a class or function depending on the language you are using and then call that code from both the functions

- 3,000
- 5
- 12