I run on Debug the console program and this recognize all functions but I can't trigger any function.
Based on your code, I tested it on my side and found that when my firstly debug the application, then I could get the following output:
But, when I restarted the application, I found that it would take some time for the function to be triggered.
Please make sure that you have installed the latest version packages of "Microsoft.Azure.WebJobs" and "Microsoft.Azure.WebJobs.Extensions". For more details, you could follow this tutorial.
And please try to reduce the time interval in your TimerTrigger
and wait for a period when the job host has started, then try to find out whether the function could be triggered on your side. Here is my code sample, you could refer to it.
Program.cs
static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
// Add Triggers and Binders for Timer Trigger.
config.UseTimers();
JobHost host = new JobHost(config);
//host.RunAndBlock();
host.Start();
Console.WriteLine("[{0}] Job Host started!!!", DateTime.Now);
Console.ReadLine();
}
Function.cs
//Function triggered by a timespan schedule every 5 sec.
public static async void ProcessAugustEndowments([TimerTrigger("*/5 * * * * *", RunOnStartup = true)] TimerInfo timerInfo)
{
Console.WriteLine("Endowments process tried");
await endowmentNotification();
}
private static async Task endowmentNotification()
{
//sleep for 2 sec to simulate processing business logic
await Task.Delay(TimeSpan.FromSeconds(2));
}
Additionally, if the TimerTrigger
could not meet your requirement, you could refer to this official tutorial to create a schedule WebJob, also you could refer to this blog.
ProcessAugustEndowments
from yourMain()
method. Comment or#ifdef
around thehost.RunAndBlock()
method I expect you have. – Dean GoodmanTimerTrigger
? did you configure your jobhost to use timersconfig.UseTimers();
? – Thomas