I am using .NET 5 and developing Azure Functions. When adding a new Timer Trigger function through Visual Studio it adds a file with this content:
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
I'm including it as a photo here to highlight that it doesn't compile because the TimerTrigger class doesn't exist.
Intellisense suggests that I add the following using:
using Microsoft.Azure.WebJobs;
But that doesn't make sense, because that belongs to the previous version of Azure Functions. And sure enough, Intellisense detects this and show this error.
So how do I use TimerTrigger in .NET 5?
Maybe because this is relatively new, there seems to be no documentation or popular posts about this yet.
Try the Microsoft.Azure.Functions.Worker.Extensions.Timer
package, as documented here:
Because functions that run in a .NET isolated process use different binding types, they require a unique set of binding extension packages.
You'll find these extension packages under Microsoft.Azure.Functions.Worker.Extensions.
Direct link to NuGet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With