简体   繁体   English

从 DevOps 调度多个 Webjob 的最简单方法

[英]Simplest Way to Schedule Multiple Webjobs from DevOps

I have an app service in Azure running the front end from my MVC5 app, and another app service for web jobs.我在 Azure 中有一个从我的 MVC5 应用程序运行前端的应用程序服务,以及另一个用于 Web 作业的应用程序服务。 The app has several endpoints (GET Actions) which do some processing, send some emails or other simple task.该应用程序有多个端点(GET 操作),它们执行一些处理、发送一些电子邮件或其他简单任务。 Previously when we were hosted on a VPS, we used the Windows Task Scheduler to call each URL on a custom schedule.以前,当我们托管在 VPS 上时,我们使用 Windows 任务计划程序按自定义计划调用每个 URL。 In Azure, the way we're currently doing this is with a Powershell script which uses CURL to fetch the URL and trigger the processing.在 Azure 中,我们目前采用的方法是使用 Powershell 脚本,该脚本使用 CURL 获取 URL 并触发处理。

It seems messy though - as each powershell script has to be uploaded individually, and can't be viewed or changed after uploading.虽然看起来很乱 - 因为每个 powershell 脚本都必须单独上传,并且在上传后无法查看或更改。 I've found various guides on deploying a .NET Core console app, but from what I can tell each job would need it's own project, deployed with it's own pipeline.我找到了有关部署 .NET Core 控制台应用程序的各种指南,但据我所知,每个作业都需要自己的项目,并使用自己的管道进行部署。

Is there a nicer way of doing this, are Webjobs even the right tool for this job, given the seemingly simple task we're performing.考虑到我们正在执行的看似简单的任务,是否有更好的方法来做到这一点,Webjobs 是否甚至是这项工作的正确工具。

As far as I understand your use case, you can use Azure Function App Timer Trigger to accomplish it.据我了解您的用例,您可以使用Azure Function App Timer Trigger来完成它。

A timer trigger lets you run a function on a schedule.计时器触发器可让您按计划运行函数。

The following example shows a C# function that is executed each time the minutes have a value divisible by five (eg if the function starts at 18:57:00 , the next performance will be at 19:00:00 ).下面的示例示出了由5每次分钟有一个值整除执行的C#函数(例如,如果在函数开始18:57:00 ,接下来的性能将在19:00:00 )。 The TimerInfo object is passed into the function. TimerInfo对象被传递到函数中。

[FunctionName("TimerTriggerCSharp")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
    if (myTimer.IsPastDue)
    {
        log.LogInformation("Timer is running late!");
    }
    log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}

The attribute's constructor takes a CRON expression or a TimeSpan .该属性的构造函数采用CRON表达式或TimeSpan You can use TimeSpan only if the function app is running on an App Service plan.仅当函数应用在应用服务计划上运行时,才能使用TimeSpan TimeSpan is not supported for Consumption or Elastic Premium Functions . Consumption or Elastic Premium Functions不支持TimeSpan

CRON (NCRONTAB expressions) CRON(NCRONTAB 表达式)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有办法在 Azure Devops 的一个解决方案中引用多个项目? - Is there a way to have multiple projects referenced in one solution with Azure Devops? 将ASP.NET MVC 3站点部署到尚未运行Web服务器的多个客户端的最简单方法是什么? - What is the simplest way to deploy an ASP.NET MVC 3 site to multiple clients that are not already running a web server? 从Twitter获取5条最新推文的最简单方法,用于ASP.Net Webforms - Simplest way to get 5 most recent tweets from twitter for ASP.Net Webforms 从应用程序路径生成特定于域的URL的最简单方法是什么? - What is the simplest way to generate domain specific url from application path..? 从C#发送和接收基本肥皂消息的最简单方法是什么? - what is the simplest way to send and receive a basic soap message from C#? 测试从某些JavaScript返回JSON的ASP.NET Webservice的最简单方法是什么? - Simplest way to test ASP.NET Webservice that returns JSON from some JavaScript? 在.NET中调用HttpHandler文件的最简单方法是什么? - What is the simplest way to call an HttpHandler file in .NET? 一次检查DBNull和null的最简单方法 - Simplest way to check for DBNull and null at once 在Visual Studio中创建reactjs应用的最简单方法 - simplest way to create reactjs app in visual studio IIS 7.5-创建虚拟目录的最简单方法 - iis 7.5 - simplest way of creating a virtual directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM