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.
...
I have defined my timer trigger functions using the Function attribute in the isolated worker model.
Configuration values for my timers are stored in the host.json file like this:
{
"version": "2.0",
"AppConfigOptions": {
"MyTimerValue": "0 */5 * * * *",
"AnotherTimerValue": "0 0 * * * *"
}
}
[Function("MyTimerFunction")]
public void RunMyTimerFunction(
[TimerTrigger("%AppConfigOptions:MyTimerValue%")] TimerInfo timer,
FunctionContext context)
{
var logger = context.GetLogger("MyTimerFunction");
logger.LogInformation("Function executed");
}
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?
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)