Currently I’m only using Hangfire for the IBackgroundProcess, no jobs just yet. Running as Azure Web App it stops executing randomly.
This is all the code for hangfire in a standard empty MVC 5 website
Configured the Azure Web App as Always Running = yes.
public class MyBackgroundProcess: IBackgroundProcess
{
public void Execute(BackgroundProcessContext context)
{
Trace.TraceInformation("I'm running...");
...
context.Wait(TimeSpan.FromSeconds(5));
}
}
and then I the registration in Startup.cs with a default connection to an azure sql database.
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
app.UseHangfireDashboard();
app.UseHangfireServer(new MyBackgroundProcess());
}
}
Is this a known issue or is it what I’m expecting that MyBackgroundProcess would be always running? It sometimes stops after running 2 hours and sometimes after 20 hours, randomly.