c# - Azure Function 无法从设置加载 CRON 计时器

标签 c# azure azure-functions

我有一个用 C# 编写的 Azure 函数,并直接从 Visual Studio 使用 Zip 部署进行预编译部署。尽管在本地一切正常,但该函数在启动时会抛出错误

Function (RunStatsRecalculation) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'RunStatsRecalculation'. Microsoft.Azure.WebJobs.Host: '%TimerInterval%' does not resolve to a value.

定时器设置的 CRON 表达式存储在键 TimerInterval 下的设置中,值为 “0 0 0 * * *”

函数定义如下

    [FunctionName("RunStatsRecalculation")]
    public static async Task Run(
        [TimerTrigger("%TimerInterval%")]TimerInfo myTimer,
        ILogger logger,
        ExecutionContext context,
        CancellationToken ct)
    {

知道可能出了什么问题吗?

最佳答案

我可以重现您的问题。要解决此问题,请将键(TimerInterval)和值(0 0 0 * * *)添加到azure函数应用程序设置中。

这是我的代码:

        [FunctionName("Function1")]
        public static void Run([TimerTrigger("%TimerSchedule%")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
            log.LogInformation($"this is a test for timer trigger...");
        }

和应用程序设置:

enter image description here

关于c# - Azure Function 无法从设置加载 CRON 计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57215258/

相关文章:

c# - 让 ZedGraph 使用科学计数法而不是工程计数法的最简单方法是什么?

c# - 发布到 Azure 时 Visual Studio 崩溃

Azure函数: Autoscale is currently not available for this resource

Azure Function Web 套接字客户端

javascript - 在 Azure Functions Typescript 中使用 IBinder?

c# - 从 WebApi 接收 IActionResult

c# - 检查 Binary Formatter 的序列化是否已完成

c# - 模仿 Gtk#/gtk-sharp 中的上下文菜单

azure - 在 Azure Power BI 中从外部指定视觉效果参数

azure - Azure 存储表上的 PartitionKey 和 RowKey