Convert .NET Windows Service to Azure Web Job

Viewed 6168

I have a .NET Windows Service and would like to convert to Azure Web Jobs. Please let me know if I can host it as an Azure Web Jobs or a recommendation to convert.

2 Answers

You can't unfortunately directly host Windows Services in Azure PaaS solutions, unless it is built using TopShelf. Your options are:

  1. Use Azure Virtual Machine to host the Windows Service
  2. Convert the Windows Service so that it can be hosted in Azure PaaS

For conversion the simplest plan is usually the following:

  1. Create a new .NET Console application
  2. Move all the logic from your Windows Service into the .NET Console app
  3. Make the console app work so that once you run it, it executes the logic and exits. So no while loop which keeps the console app running forever.
  4. Publish the console app as a Web Job. You can publish it directly from Visual Studio or upload it using Azure Portal.
  5. Schedule the web job to execute when needed.

You can skip the conversion part if your service uses TopShelf.

If your Windows Service is doing something else than just executing simple logic, for example it hosts WCF or Web Api, the easiest option usually is to convert it into a web app.

Related