将 C# 控制台应用程序发布为 Azure Web 作业

Publishing a C# console application as an Azure web job

我在 VM 上有一个控制台应用程序,具有日志记录、调度等功能,运行。它适用于 Entity Framework、Azure SQL 服务器、Azure blob 存储和大量外部 API。

我想把它变成一项服务。

我知道这可以通过辅助角色来完成,但是查看辅助角色的各种教程,似乎重写整个内容需要大量工作。

如果我只是将其发布为 Web 作业,假设我没有任何公开的端点,这是否安全?我需要确保活动目录之外的任何人都无法访问它。

有没有一种方法可以创建一个没有端点的虚拟应用服务并将其发布到那里?

If I just publish it as a web job, will this be secure, assuming I don't have any exposed endpoints? I need to make sure that nobody outside our active directory can access it.

正如 Peter Bons 所说,如果它不公开 API 或端点,则没有人可以访问它。

Is there a way that I can create a dummy app service which will have no endpoints and publish it there?

通常我们 运行 Azure 应用服务网络应用中的 WebJobs,并且该 Azure 应用服务网络应用可以 accessed/browsed 通过 URL。如果要阻止用户浏览该 Azure App Service Web 应用程序,可以将站点的 web.config 重写规则添加到 block web access

<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">  
<match url=".*" />  
<conditions>  
<!-- Enter your site host name here as the pattern-->  
<add input="{HTTP_HOST}" pattern="^sitehostname\." />  
<!-- Enter your white listed IP addresses -->  
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>  
<!-- Add the white listed IP addresses with a new condition as seen below -->  
<!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->  
</conditions>  
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"  
statusDescription="Site is not accessible" />  
</rule> 

你的 exe 到底是什么?有人会定期调用它并安排 运行 吗? 我们这里有几个选项,如果处理逻辑不复杂,您可以为它配置 Azure functions which uses WebJobs SDK itself but doesn't require an App Service。 或者您可以选择 Azure Scheduler,它可以按预定的时间间隔获取您的可执行文件和 运行。