I’m excited to announce the release of my third and latest course at Pluralsight! This new course covers building ASP.NET Core hosted services and .NET Core worker services.
When I first pitched the course proposal to Pluralsight, I was quite surprised that it hadn’t been covered in great detail already. In my daily work, building .NET services that form part of a microservice-based architecture, I have developed numerous worker services.
I was therefore really passionate about putting together a course which covers the critical concepts of hosted services and worker services.
My objective with this course is to not just to lay the foundational concepts. I wanted to introduce them with practical examples, based on real-world services which I have been involved in developing.
I’ve worked closely with the team at Microsoft in my endeavour to cover all of the topics which are most crucial to understand. I owe thanks to Glenn, Ryan, Brady and the ASP.NET team for their support during the development of the content.
I researched and developed the content included in the course over four months. In total, I spent around 120 hours building demos, scripting the material and recording the course. I’ve aimed to keep the course a length that can be practically consumed in a couple of lunchtimes.
After some feebback from my previous courses I have adjusted how I produce the sample code in the excercise files so that it’s hopefully easier to pick and follow along with the various clips.
For me, these courses are a labour of love as I’m passionate about helping others leverage the full potential of these features. If you have a subscription to Pluralsight already, I hope you’ll add this course to your bookmarks for future viewing. If you don’t yet have a subscription, you can sign up for access to this content and so many other fantastic courses.
Module Summaries
Background Tasks in ASP.NET Core Applications
In this first module, I describe some potential use cases for hosted services, which can be applied in ASP.NET Core applications to perform background workloads.
We’ll develop two hosted services together. The first will show you how a hosted service might be used to pro-actively populate a cache of data at regular intervals. The second will focus on improving application responsiveness by moving a slow processing workload out of the web request lifecycle. We’ll use Channels, a relatively new feature in .NET Core to transfer data between the web requests and a hosted service which then performs the processing in the background.
We’ll Cover:
- Creating a Hosted Service
- What are Hosted Services?
- Coordinating Between Requests and Background Services
- Processing Channel Messages in Background Services
Building .NET Core Worker Services
In this module, we’ll move onto building .NET Core worker services from scratch. We’ll start from the worker service template, building up a .NET Core microservice which will process messages from a queue. We’ll eventually use this service to remove the processing workload that we handled using a hosted service in the ASP.NET Core web application.
We’re beginning to break of logic units of functionality as microservices. We’ll decouple the web application and the worker service using some Amazon Web Services features such as Simple Queue Service and Simple Storage Service.
We’ll Cover:
- What Are Worker Services?
- Worker Service Architecture
- Creating a Worker Service
- Hosting in .NET Core
- AWS and LocalStack Set Up
- Reading From a Queue
- Processing Messages From a Channel
- Refactoring the Web Application
Advanced Hosted Service Concepts
With the first two modules introducing the core concepts and building out quite basic hosted services and using the worker service template, this module dives deeper. We’ll cover more advanced topics that you will likely encounter as you begin building your own services. For example, we’ll extend the demos to consider things such as exception handling and application lifetime management. We’ll also take a look at how to unit test a hosted service and some gotchas you may encounter.
We’ll Cover:
- BackgroundService Implementation Details
- Handling Exceptions In Hosted Services
- Handling Application Shutdown
- Registration Order of Hosted Services
- Configuring the Host
- Overriding StartAsync or StopAsync In BackgroundServices
- Testing Worker Services
- Avoiding Blocking Code in StartAsync
Running Worker Services in Production
This final module closes by introducing some potential options for running worker services in production. There’s little point in developing services unless you have a plan for how you are going to operate them in production. This module is packed with demos!
We’ll Cover:
- Docker Primer
- Running Worker Services as Containers
- Running Worker Services as Windows Services
- Running Worker Services as Linux Daemons
- Running a Worker Service on Azure App Service
I really hope that you find the content in this course useful and practical. I’ve taken the feedback from my previous two courses to try to make this my best course yet! Do let me know how you get on with the course if you fit it into your busy schedule.
If you haven’t already, you can check out my previous courses:
- Dependency Injection in ASP.NET Core
- Using Configuration and Options in .NET Core and ASP.NET Core Apps
Of course, you can also follow me directly on Pluralsight to get notified when I release new content.
Have you enjoyed this post and found it useful? If so, please consider supporting me: