【发布时间】:2021-07-13 10:41:43
【问题描述】:
我正在使用 .NET 5 并开发 Azure Functions。通过 Visual Studio 添加新的 Timer Trigger 函数时,它会添加一个包含以下内容的文件:
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}");
}
}
我在这里将它作为照片包含在内,以强调它无法编译,因为 TimerTrigger 类不存在。
Intellisense 建议我使用以下方法添加以下内容:
using Microsoft.Azure.WebJobs;
但这没有意义,因为它属于以前版本的 Azure Functions。果然,Intellisense 检测到这一点并显示此错误。
那么如何在 .NET 5 中使用 TimerTrigger?
也许因为这是相对较新的,似乎还没有关于此的文档或热门帖子。
【问题讨论】:
标签: c# azure azure-functions .net-5