Azure Functions Timer Trigger Configuration Not Resolving After Upgrading to .NET 8 - Stack Overflow

admin2025-04-25  2

I’m encountering an issue with my Azure Functions app after upgrading from .NET 6 to .NET 8. My timer trigger functions fail to resolve configuration values, and I get the following errors when I run the Function App locally:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.MyTimerFunction'.
Microsoft.Azure.WebJobs.Host: '%AppConfigOptions:MyTimerValue%' does not resolve to a value.

[2025-01-15T18:00:05.218Z] Function 'Functions.MyTimerFunction' failed indexing and will be disabled.
[2025-01-15T18:00:05.220Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.AnotherTimerFunction'.
Microsoft.Azure.WebJobs.Host: '%AppConfigOptions:AnotherTimerValue%' does not resolve to a value.
...
  1. I have defined my timer trigger functions using the Function attribute in the isolated worker model.

  2. Configuration values for my timers are stored in the host.json file like this:

     {
          "version": "2.0",
          "AppConfigOptions": {
            "MyTimerValue": "0 */5 * * * *",
            "AnotherTimerValue": "0 0 * * * *"
          }
        }
  1. My timer function looks like this:
[Function("MyTimerFunction")]
public void RunMyTimerFunction(
    [TimerTrigger("%AppConfigOptions:MyTimerValue%")] TimerInfo timer,
    FunctionContext context)
{
    var logger = context.GetLogger("MyTimerFunction");
    logger.LogInformation("Function executed");
}
  1. After upgrading to .NET 8, the placeholder %AppConfigOptions:MyTimerValue% does not resolve, even though it worked perfectly in .NET 6.

Question: What could cause configuration placeholders like %AppConfigOptions:MyTimerValue% to stop resolving after upgrading to .NET 8? How can I fix this so my timer triggers work as expected in the isolated worker model?

I’m encountering an issue with my Azure Functions app after upgrading from .NET 6 to .NET 8. My timer trigger functions fail to resolve configuration values, and I get the following errors when I run the Function App locally:

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.MyTimerFunction'.
Microsoft.Azure.WebJobs.Host: '%AppConfigOptions:MyTimerValue%' does not resolve to a value.

[2025-01-15T18:00:05.218Z] Function 'Functions.MyTimerFunction' failed indexing and will be disabled.
[2025-01-15T18:00:05.220Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.AnotherTimerFunction'.
Microsoft.Azure.WebJobs.Host: '%AppConfigOptions:AnotherTimerValue%' does not resolve to a value.
...
  1. I have defined my timer trigger functions using the Function attribute in the isolated worker model.

  2. Configuration values for my timers are stored in the host.json file like this:

     {
          "version": "2.0",
          "AppConfigOptions": {
            "MyTimerValue": "0 */5 * * * *",
            "AnotherTimerValue": "0 0 * * * *"
          }
        }
  1. My timer function looks like this:
[Function("MyTimerFunction")]
public void RunMyTimerFunction(
    [TimerTrigger("%AppConfigOptions:MyTimerValue%")] TimerInfo timer,
    FunctionContext context)
{
    var logger = context.GetLogger("MyTimerFunction");
    logger.LogInformation("Function executed");
}
  1. After upgrading to .NET 8, the placeholder %AppConfigOptions:MyTimerValue% does not resolve, even though it worked perfectly in .NET 6.

Question: What could cause configuration placeholders like %AppConfigOptions:MyTimerValue% to stop resolving after upgrading to .NET 8? How can I fix this so my timer triggers work as expected in the isolated worker model?

Share Improve this question asked Jan 16 at 12:47 Dilshan PrasadDilshan Prasad 819 bronze badges 1
  • You need to add the placeholders in local settings file instead of host.json – Ikhtesam Afrin Commented Jan 16 at 13:08
Add a comment  | 

1 Answer 1

Reset to default 2

You need to add the placeholders in local settings file in the given manner.

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
        "AppConfigOptions__MyTimerValue": "0 */2 * * * *",
        "AppConfigOptions__AnotherTimerValue": "0 0 * * * *"
  }
}

Then, use it in function code as shown below.

[Function("MyTimerFunction")]
public void Run([TimerTrigger("%AppConfigOptions:MyTimerValue%")] TimerInfo myTimer)
{
    _logger.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
    
    if (myTimer.ScheduleStatus is not null)
    {
        _logger.LogInformation($"Next timer schedule at: {myTimer.ScheduleStatus.Next}");
    }
}

This will work as expected.

Azure Functions Core Tools
Core Tools Version:       4.0.6821 Commit hash: N/A +c09a2033faa7ecf51b3773308283af0ca9a99f83 (64-bit)
Function Runtime Version: 4.1036.1.23224

[2025-01-16T14:20:50.124Z] Found C:\Users\*****\FunctionApp12\FunctionApp12\FunctionApp12.csproj. Using for user secrets file configuration.
[2025-01-16T14:20:53.081Z] Azure Functions .NET Worker (PID: 24976) initialized in debug mode. Waiting for debugger to attach...
[2025-01-16T14:20:53.118Z] Worker process started and initialized.

Functions:

        MyTimerFunction: timerTrigger

For detailed output, run func with --verbose flag.
[2025-01-16T14:20:58.140Z] Host lock lease acquired by instance ID '0000000000000000000000000D2022A4'.
[2025-01-16T14:22:00.080Z] Executing 'Functions.MyTimerFunction' (Reason='Timer fired at 2025-01-16T19:52:00.0311396+05:30', Id=ce26f2f7-6a90-47dc-b521-533a72e86837)
[2025-01-16T14:22:00.347Z] C# Timer trigger function executed at: 16-01-2025 19:52:00
[2025-01-16T14:22:00.351Z] Next timer schedule at: 16-01-2025 19:52:00
[2025-01-16T14:22:00.370Z] Executed 'Functions.MyTimerFunction' (Succeeded, Id=ce26f2f7-6a90-47dc-b521-533a72e86837, Duration=336ms)
转载请注明原文地址:http://anycun.com/QandA/1745531608a90843.html