为什么我的 Azure WebJob 没有计划?
Why isn't my Azure WebJob scheduled?
我有一个 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 只是一个由计时器触发的 On-demand/Triggered WebJob。现在这个计时器可以是 Azure 调度程序(这是 VS 工具用来创建的)或 Kudu 中的内置调度程序。
要使用内置调度程序,请在项目的根目录中创建名为 settings.job
的文件并将其作为内容:
{
"schedule": "0 0 * * * *"
}
每小时都会运行。它使用 CRON 表达式,在这种情况下定义它应该 运行 始终在秒和分钟为零时。现在这确实需要在应用程序中打开 Always On。
文档:https://docs.microsoft.com/en-gb/azure/app-service/web-sites-create-web-jobs#CreateScheduledCRON
我有一个 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 只是一个由计时器触发的 On-demand/Triggered WebJob。现在这个计时器可以是 Azure 调度程序(这是 VS 工具用来创建的)或 Kudu 中的内置调度程序。
要使用内置调度程序,请在项目的根目录中创建名为 settings.job
的文件并将其作为内容:
{
"schedule": "0 0 * * * *"
}
每小时都会运行。它使用 CRON 表达式,在这种情况下定义它应该 运行 始终在秒和分钟为零时。现在这确实需要在应用程序中打开 Always On。
文档:https://docs.microsoft.com/en-gb/azure/app-service/web-sites-create-web-jobs#CreateScheduledCRON