I'm trying to run an Azure Functions project (v3) using .NET 5 however I get the error that no job functions are found. The exact error is this:
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
I have a program.cs
file which looks like this:
class Program
{
static Task Main(string[] args)
{
var host = new HostBuilder()
.ConfigureWebJobs(builder =>
{
builder.AddTimers();
builder.AddAzureStorage();
})
.ConfigureLogging((context, b) =>
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddConsole();
})
.Build();
return host.RunAsync();
}
}
And I added a timer triggered function looking like this:
public class CleanUp
{
[FunctionName(nameof(CleanUp))]
public static void CleanUpWebJob([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer,
ILogger log) // every one minute
{
if (myTimer.IsPastDue)
{
log.LogInformation("Timer is running late!");
}
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
Obviously I also changed my project file so it runs the v3 correctly. This works fine, I can run the project and see a console window. It's just that the web job is not discovered.