0

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());

1 Answers1

1

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

Doris Lv
  • 3,083
  • 1
  • 5
  • 14
  • Thanks, but I'm running a continuous webjob and require the cron to trigger a function. Will this resolve for continuous webjob as well? – user3627341 Aug 26 '20 at 08:14
  • Of course it works for continuous webjob, cause I use continuous webjob for testing this.@user3627341 – Doris Lv Aug 26 '20 at 08:19
  • How about a scenario wherein I have multiple functions and multiple cron expressions. I would like to not give "schedule" in settings.job but other app settings keys that shall contain cron expressions. This is another issue I faced now. – user3627341 Aug 26 '20 at 12:33
  • I'm afraid it is not possible to set multiple cron expressions in one WebJob, @user3627341. You can refer to the picture I updated in my answer. – Doris Lv Aug 27 '20 at 02:29
  • Hey, @user3627341 .If you think my answer is useful, please accept it by clicking on the ✔, so more people would see it. – Doris Lv Sep 01 '20 at 08:25