Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert .NET Windows Service to Azure Web Job

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.

like image 437
user1663715 Avatar asked Oct 26 '25 03:10

user1663715


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.

like image 161
Mikael Koskinen Avatar answered Oct 28 '25 17:10

Mikael Koskinen


You could convert your service to a console application and run it as a continuous web job. Simply put a run.cmd inside the same directory that will start your .exe file (see Run Background tasks with WebJobs in Azure App Service).

like image 27
Dennis Ziegan Avatar answered Oct 28 '25 19:10

Dennis Ziegan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!