Search code examples
c#azureazure-webjobsazure-webjobssdkazure-webjobs-continuous

Azure WebJobs 3.x does not trigger with CRON expression in Azure Application Settings


Environment: .Net Framework 4.7.2

Application settings being read from: app.config, no applicationsettings.json in the project

Issue: Environment variable doesn't override the CRON expression in project.exe.config (one in Kudu) and trigger. All other app settings are getting overridden but CRON expression.

Here is my builder:

var builder = new HostBuilder();
var resolver = new myNameResolver();
builder.ConfigureWebJobs(buil =>
{
   buil.AddAzureStorageCoreServices();
   buil.AddAzureStorage();
   buil.AddServiceBus(servBus=>
   {
     servBus.MessageHandlerOptions.AutoComplete = false;
     servBus.MessageHandlerOptions.MaxConcurrentCalls = myMaxConcurrentCalls;
     servBus.ConnectionString = myServiceBusConnectionString;
     servBus.MessageHandlerOptions.MaxAutoRenewDuration = TimeSpan.FromHours(12);
    });
    buil.AddTimers();
});
builder.ConfigureServices(serv => serv.AddSingleton<INameResolver>(resolver));
builder.ConfigureHostConfiguration(config =>
{
  config.AddInMemoryCollection(BuildConfiguration(myStorageConnectionString));
  config.AddEnvironmentVariables();
});
builder.ConfigureAppConfiguration(buil => buil.AddEnvironmentVariables());

Solution

  • Do you notice the settings.job file after click publish as Azure WebJob... in Visual Studio? I'm afraid the CRON setting haven't been read.

    You should use that file to set schedule for your WebJob, and set your settings.job file properties in Visual Studio as Copy if newer. enter image description here

    This file will be stored in Kudu, too. enter image description hereMore details about WebJobs you can refer to this.

    For your question multiple functions with multiple schedules in one WebJob, it seems not possible.

    enter image description here