How to work with worker services in ASP.Net Core
ASP.Net Core 3.0 Preview 3 adds support for creating worker services, which are background services like Windows services and Linux daemons. There is a new template for creating a worker service in Visual Studio as well.
To work with worker services in Visual Studio, you should have the beta versions (Preview Version 3 or later) of ASP.Net Core 3.0 and .Net Core 3.0 runtimes installed on your system.
Create a new worker service application
First, let’s create an ASP.Net Core project in Visual Studio 2019. Follow these steps o create a new ASP.Net Core project in Visual Studio:
- Launch the Visual Studio IDE.
- Click Create New Project.
- In the Create New Project window, select ASP.Net Core Web Application from the list of templates.
- Click Next.
- In the Configure Your New Project window that appears, specify the name and location for the new project.
- Click Create.
- The window Create New ASP.Net Core Web Application appears.
- Select .Net Core as the runtime and ASP.Net Core 3.0 (or later) from the dropdown menu at the top.
- Select Worker Service as the project template to create a new worker service application
- Ensure that the check box Enable Docker Support is unchecked, because you won’t be using this feature here.
- Ensure that Authentication is set as No Authentication, because you won’t be using authentication either.
- Click Create.