Search code examples
c#.netazureazure-web-app-serviceazure-webjobs

Continuous WebJob don't start


I'm trying to deploy Continuous WebJob (.NET Core 3.1) that have a function with NoAutomaticTrigger attribute. Here is my code.

[NoAutomaticTrigger]
public async Task StartProcessingTest(ILogger logger)
{
    await FindActiveContainers(logger);
}

The main method:

static async Task Main(string[] args)
{
    _configuration = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("appsettings.json", false, true)
        .Build();

    var builder = new HostBuilder();

    builder.ConfigureWebJobs(b => b.AddAzureStorageCoreServices());
    builder.ConfigureLogging(b =>
    {
        b.AddConsole();
    });
    builder.ConfigureServices((hostContext, services) =>
    {
        services.AddSingleton(_configuration);
        services.BuildServiceProvider();
    });

    var host = builder.Build();
    using (host)
    {
        await host.RunAsync();
    }
}

As I can see the job starts without any exceptions, but for some reasons, the function StartProcessingTest didn't trigger at the start. enter image description here

enter image description here


Solution

  • It seems you didn't invoke your StartProcessingTest function in your main code.

    If the problem still exist, check if you publish the connectionstring.

    Here is the official document about manual trigger.

    You could invoke like this:

     await jobHost.CallAsync("CreateQueueMessage", inputs);