This answer comes late, but it saved me some hassle.
It is very similar to the previous answer https://mcmap.net/q/1667306/-how-to-get-hangfire-started-quot-always-on-quot-in-azure-shared-hosting and applies the same principle using Hangfire since it's already part of the app.
Use Azure Scheduler to ping you web page to keep it alive ;-) You can create up to 5 jobs with maximum execution every hour with FREE tier. Which means that you can create 5 jobs which will ping you website every 12 minutes.
I had to run a very simple site with Hangfire jobs in Azure that would do some processing. Scaling it up to a B plan or above just to have Always On was going to bee too pricey for this.
A workaround to keeping the app service always on in the Free tier was to create a scheduled Hangfire job that would run every 10 minutes after the site starts and ping itself.
Even if your app doesn't need Hangfire, you can just drop it in there for the sake of the scheduled job and use and event use InMemory storage to persist the job, as long as it pings the site every 10 minutes.
This will keep the app service warmed up and always on without exhausting the usage quota - the daily CPU time consumption of this is probably less than 10 seconds, which is well under the daily 60 minutes limit of the Free tier. DB DTU consumption is also very low in the case of an Azure SQL database.
Example job setup:
// Call this right after your app service starts.
RecurringJob.AddOrUpdate<PingJob>("Azure Always On", x => x.PingAsync("https://<yousite>.azurewebsites.net/"), "*/10 * * * *");
And the implementation of the PingJob
, using package Flurl.Http
to keep it super simple:
using Flurl.Http;
namespace YourAwesomeApp;
public class PingJob
{
public Task PingAsync(string url) => url.GetAsync();
}