2
votes

I have an Azure Function written in C# and deployed as pre-compiled using Zip deploy directly from Visual Studio. Although on local everything works the function throws an error upon starting

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

The CRON expression for timer setting is stored in the settings under key TimerInterval with value "0 0 0 * * *"

The function is defined as follows

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

Any idea what could be wrong?

1

1 Answers

3
votes

I can repro your issue. To resolve the issue, please add the key(TimerInterval) and value(0 0 0 * * *) to azure function application settings.

Here is my code:

        [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...");
        }

And application settings:

enter image description here