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

时间:2017-07-06 08:52:34

标签: c# azure azure-webjobs

我有一个控制台应用程序,在VM上运行日志记录,日程安排等。它适用于Entity Framework,Azure SQL Server,Azure blob存储和一堆外部API。

我想把它变成一项服务。

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

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

有没有办法可以创建一个没有端点并在那里发布的虚拟应用服务?

2 个答案:

答案 0 :(得分:2)

  

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

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

  

有没有办法可以创建一个没有端点并在那里发布的虚拟应用服务?

通常我们在Azure App Service Web应用程序中运行WebJobs,并且可以通过URL访问/浏览Azure App Service Web应用程序。如果您想阻止用户浏览到该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> 

答案 1 :(得分:1)

你的exe究竟是什么?有人会调用它并计划定期运行吗? 我们在这里有几个选项,如果处理逻辑不复杂,您可以使用Azure functions本身使用WebJobs SDK,但不需要为其配置App Service。 或者你可以去Azure Scheduler,它可以带你的可执行文件并按计划的时间间隔运行。

相关问题