将 windows 服务发布为 AZURE WEBJOB

Publishing a windows service as a AZURE WEBJOB

我有一个 NserviceBus 处理程序,它通常作为服务安装在 VM 上。我们正试图让它作为一个 PAAS 在 Azure 上运行。因此,我们的想法是将解决方案发布为 azure webjob。当我将其发布为 Web 作业时,我会在其上获得待定启动状态。日志指示以下内容。

[02/27/2017 09:35:10 > 2cf107: SYS INFO] Run script 'ENSource.Handlers.exe' with script host - 'WindowsScriptHost'
[02/27/2017 09:35:10 > 2cf107: SYS INFO] Status changed to Running
[02/27/2017 09:35:10 > 2cf107: INFO] Cannot start service from the command line or a debugger.  A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.
[02/27/2017 09:35:10 > 2cf107: SYS INFO] Status changed to Success
[02/27/2017 09:35:10 > 2cf107: SYS INFO] Process went down, waiting for 60 seconds
[02/27/2017 09:35:10 > 2cf107: SYS INFO] Status changed to PendingRestart

我错过了什么?如何让 NServiceBus 处理程序在 Azure 上作为 WebJobs 工作?

它不能与 Azure Web Jobs 一起使用,您可以尝试 运行 它作为具有提升权限的云服务,但我不确定它是否会给您安装它作为 [= =12=]服务。所以恐怕除了使用虚拟机之外别无他法。如果您想要一个 PaaS 替代方案,您可以尝试使用 Azure 服务总线重写您的应用程序的这一部分。

我将重写该服务,使其不再是 Windows 服务,而是控制台应用程序。如果这对您的场景更有意义,您可以告诉 WebJob 主机 run it on a schedule (or make it continuous by leveraging the WebJobs SDK

另一种方法,如 Thiago 所述,是将 Windows 服务安装在 Cloud Services 的 Worker 角色中: https://blogs.msdn.microsoft.com/golive/2011/02/11/installing-a-windows-service-in-a-windows-azure-worker-role/

做起来不是很直接,但也不可怕。