我有一个 ASP.NET MVC5 应用程序在 Azure 中作为应用服务运行,并且希望安排一个 WebJob 每小时执行一个控制台应用程序。
在控制台应用程序中,我将 webjob-publish-settings.json
文件定义为:
{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "EpisodeUpdater",
"startTime": "2017-05-01T00:00:00-08:00",
"endTime": "2020-06-01T00:00:00-08:00",
"jobRecurrenceFrequency": "Hour",
"interval": 1,
"runMode": "Scheduled"
}
When I look in the Azure portal the type of WebJob appears to be set as Triggered - the job will run successfully when I start it manually but it doesn't execute every hour.
谁能明白为什么 WebJob 没有正确安排吗?
最佳答案
在某种程度上,没有预定的作业。计划的 WebJob 只是由计时器触发的按需/触发的 WebJob。现在这个计时器可以是 Azure Scheduler(这是 VS 工具用来创建的)或 Kudu 中的内置调度程序。
要使用内置调度程序,您可以在项目的根目录中创建名为 settings.job
的文件,并将其作为内容:
{
"schedule": "0 0 * * * *"
}
这将每小时运行一次。它使用 CRON 表达式,在本例中定义它应该始终在秒和分钟为零时运行。现在,这确实需要在应用程序中启用“始终开启”。
文档:https://learn.microsoft.com/en-gb/azure/app-service/web-sites-create-web-jobs#CreateScheduledCRON
关于c# - 为什么我的 Azure WebJob 没有安排?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44021069/