Writing Windows Service in C# .NET Core for Windows & Azure Cloud

Viewed 45

Background: We have developed a Windows Service in C# .NET 4.5. The service does two jobs at once.

  1. It communicates with LDAP and reads the user statuses and updates in the Database.
  2. It communicates with the Database and rolls out items to users.

Requirement: We have got the opportunity to rewrite the service in .NET Core. We need to write the service to achieve the following targets.

  1. The old clients who are using their own infrastructure could install and use the service like they are doing now.
  2. The clients who are using CLOUD should be able to install it on the cloud. But I don't think for a single service we are required to use VM. Is there a better way to handle this scenario?
  3. The service's 1st part is communicating with LDAP. Clients who are using the cloud, definitely have the database hosted on the cloud along with the other Web Applications but where should be the service installed so it can easily communicate with the LDAP as well as with the database (2nd part)?

I heard about the background worker process. Does the windows service be used as a background worker process and as a windows service at the same time?

1 Answers

For .NET Core take a look at Microsoft.Extensions.Hosting.BackgroundService for windows services.

As far as the Cloud issue I assume it would depend on how the customer is setup. If LDAP is still on-prem, I assume it would be easier to have the service running on-prem as they would probably have a connection to the VPC on the Cloud where the database is hosted.

If everything exists on the Cloud then I assume it would the depend on the provider how you can run the service? Small EC2 instance on Amazon, on Azure you might have to use a VM or maybe look at a WebJob on an AppService, not very familiar with Google.

Hope this helps.

Related