在Windows Service和Azure WebJob之间利用单一代码库的方法 [英] Ways to leverage single code base between Windows Service and Azure WebJob

查看:38
本文介绍了在Windows Service和Azure WebJob之间利用单一代码库的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制定一个定时循环流程,在某些情况下将在OnPrem上进行部署,而在其他情况下将在云中(Azure)进行部署.我正在研究Windows服务和Azure WebJob.鉴于我只需要定期执行流程,就可以考虑在库中存储大量逻辑,而在部署到Azure时,用于本地部署的Windows Service或WebJob的入口点是不同的.每个csproj(服务和WebJob)将只处理定时循环和配置设置,然后调用库进行大部分工作.

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.

我的问题是:我是否可以使用另一种设计组合来更好地满足这些要求?我已经读过关于将现有Windows服务包装在WebJob中的信息,但是鉴于我是从头开始的,我认为在这种情况下这不是必需的.

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.

推荐答案

在保持您的通用代码最新并了解哪些应用程序使用哪个版本的情况下,下注解决方案是创建一个受尊重的类库项目.设计模式并将其转换为nuget项目.

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.

您知道您可以托管自己的私有NuGet存储库,创建自己的程序包,并将其内部托管在您自己的网络中.

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

关于如何从类库项目中创建Nuget包",这是一篇非常不错的文章.您可以利用它并在所有代码中共享它.

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.

最后,您可以从Windows服务/WebJob中调用它.

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

让我知道您是否需要与设计解决方案有关的任何帮助.

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

希望有帮助.

这篇关于在Windows Service和Azure WebJob之间利用单一代码库的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆