Azure WebJob Running after Deleted and Web App Stopped
We are testing a new WebJob to run some background processes in a Azure Web Service. The WebJob has a TimerTrigger and runs every 1 minute.
We are in early stages of development, so all the code does right now is log to our database every time it runs.
We saw records being inserted into our database so we deleted the WebJob to test a couple other things. We found that records continued to be inserted into the database after deleting the WebJob via the Portal. We proceeded to Stop the App Service entirely, but still records continued to be inserted into the database.
This SO post suggested checking for activity via the azure cli, however, an empty array is returned (same if we swap ‘triggered’ for ‘continuous’):
az webapp webjob triggered list --name my-app-name --resource-group my-rg-name
The WebJob has been deleted & the Azure App Service has been stopped for about an hour now and still we are getting records inserted into the database every minute.
Our program is not much more complicated than the .NET Core examples offered here (GitHub Azure WebJobs SDK Extensions)
We have a simple Program.cs:
var builder = new HostBuilder();
builder.ConfigureWebJobs(b =>
{
b.AddTimers();
});
builder.ConfigureLogging((context, b) =>
{
b.AddConsole();
});
var host = builder.Build();
using (host)
{
await host.RunAsync();
}
Functions.cs
public async Task Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ILogger logger)
{
var connection = _db.Connection;
await connection.ExecuteAsync("INSERT INTO webjob_logs VALUES ('test', GETDATE())");
}
Settings.job
{
"schedule": "0 */1 * * * *"
}
Read more here: Source link
