Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

c# - 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

question from:https://stackoverflow.com/questions/66051592/continuous-webjob-dont-start

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...