When running under the in-process function model, you could resolve trigger parameters from the appsettings.json – assuming its been configured as a custom configuration source as defined here.
e.g. The below timertrigger would resolve ScheduleTriggerTime from the appsettings.json file.
[FunctionName("Function1")]
public async Task Run([TimerTrigger("%ScheduleTriggerTime%")]TimerInfo myTimer)
After moving to the isolated worker model, binding from appsettings.json no longer seems to work, I can only get it to work if the setting is in the local.settings.json file.
Example code below running under the isolated model, adding appsettings.json files to the configuration, and trying to get the trigger setting ScheduleTriggerTime from said appsettings files for the TimerTrigger. Upon starting the app the error “Microsoft.Azure.WebJobs.Host: Error indexing method ‘Functions.Function1’. Microsoft.Azure.WebJobs.Host: ‘%ScheduleTriggerTime%’ does not resolve to a value.” is thrown.
Program.cs
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureAppConfiguration((hostContext, configurationBuilder) =>
{
configurationBuilder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.json")
.AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
})
.Build();
host.Run();
Function1.cs
using Microsoft.Azure.Functions.Worker;
namespace FunctionApp4
{
public class Function1
{
[Function("Function1")]
public void Run([TimerTrigger("%ScheduleTriggerTime%")] TimerInfo myTimer)
{
}
}
}
appsettings.json
{
"ScheduleTriggerTime": "0 */1 * * * *"
}
Is this an intentional change under the isolated model, or am I missing something to make this resolve the setting from the appsettings.json file?