Ways to leverage single code base between Windows Service and Azure WebJob

天大地大妈咪最大 提交于 2021-01-27 20:11:48

问题


I'm working on a timed recurring process that in some cases will be deployed OnPrem and in other cases deployed in the cloud (Azure). I'm researching a Windows Service and an Azure WebJob. Given that I only need the recurring process to be the timed piece, I'm thinking about having the bulk of the logic in a library with just the entry points being different between the Windows Service for the local deployment or a WebJob when deploying to Azure. Each csproj (service and WebJob) would handle only the timed loop and configuration settings then call into the library for the bulk of the work.

My question is: Is there another design combination available to me that would fulfill these requirements potentially in a better way? I've read about wrapping an existing windows service in a WebJob, but I don't think that would be necessary in this case given I'm starting from scratch.


回答1:


When it comes to keeping your common code up to date, and knowing which versions are used by which applications, bets solution is to create a class library project with respected design pattern and convert it into a nuget project.

you know you can host your own private NuGet repository, create your own packages, and host them internally within your own network.

Here is a very nice article for"How to create Nuget package out of your class library project". You can utilize it and share it across all your code.

And finally you can just callit from your windows service/WebJob.

Let me know if you need any help related to designing the solution.

Hope it helps.



来源:https://stackoverflow.com/questions/55578546/ways-to-leverage-single-code-base-between-windows-service-and-azure-webjob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!