To write tasks which runs in background, I always used Windows Task Scheduler or Windows Service. But ASP.NET Core is now more cross platform and these solutions are only for Windows. So recently I found a more cross platform solution which is ASP.NET Core background tasks.
Created some app with this.
GitHub – Arnab-Developer/api-health-check: Api health check app.
GitHub – Arnab-Developer/find-duplicate-bookings: Demo .NET background task application
For hosting I have below options.
- I can use a VM and deploy my app as a self contained application in a folder. Run the exe file in it.
- I can use a VM and install .NET 5 runtime just to run a console application. Deploy my application in a folder. I can open a terminal and use
dotnet myapp.dll
to run it. - I can put the app in a container and deploy in azure container instance or app service or kubernetes. I can put the container image in Docker Hub or Azure Container registry.