计划的 Web 作业混淆了计划
Scheduled web job confusing about schedule
我有一份网络工作需要每天凌晨 1 点 运行。
我的 settings.job 配置如下:
{
"schedule": "0 0 1 * * *",
"is_singleton": true
}
我在 Functions.cs
中声明了函数
namespace Dsc.Dmp.SddUpgrade.WebJob
{
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
public class Functions
{
public static void TriggerProcess(TextWriter log)
{
log.Write($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
我收到以下日志:
[09/28/2017 12:02:05 > 9957a4: SYS INFO] Status changed to Running
[09/28/2017 12:02:07 > 9957a4: INFO] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
当我阅读文档时,有些人正在使用这样的函数签名:
public static void TriggerProcess([TimerTrigger("0 0 1 * * *")] TimerInfo timerInfo, TextWriter log)
但是,这对我来说似乎不合逻辑,因为已经在 settings.job.
中按计划配置了我的 Web 作业
我在这里错过了什么?
你需要把你的逻辑放在Program.cs。
运行时间将通过执行可执行文件 运行 您的 WebJob,运行在 Program.cs 中使用 Main 方法。
如果您使用 settings.job 文件来安排您的 WebJob,您的逻辑应该放在 Program.cs 的 Main 函数中。如果你走这条路,你可以忽略 Functions.cs 文件。这对于将控制台应用程序迁移到 WebJob 并对其进行调度非常有用。
TimerTrigger 是一个 WebJob 扩展。它很有用,因为 Functions.cs 中可以有多个方法,每个方法都有一个按不同计划执行的单独 TimerTrigger。要使用这些,您的 WebJob 需要是连续的。
您似乎在函数定义中缺少 [FunctionName("TriggerProcess")] 属性,这就是您收到 "job not found" 错误的原因。
我有一份网络工作需要每天凌晨 1 点 运行。 我的 settings.job 配置如下:
{
"schedule": "0 0 1 * * *",
"is_singleton": true
}
我在 Functions.cs
中声明了函数 namespace Dsc.Dmp.SddUpgrade.WebJob
{
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
public class Functions
{
public static void TriggerProcess(TextWriter log)
{
log.Write($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
我收到以下日志:
[09/28/2017 12:02:05 > 9957a4: SYS INFO] Status changed to Running
[09/28/2017 12:02:07 > 9957a4: INFO] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
当我阅读文档时,有些人正在使用这样的函数签名:
public static void TriggerProcess([TimerTrigger("0 0 1 * * *")] TimerInfo timerInfo, TextWriter log)
但是,这对我来说似乎不合逻辑,因为已经在 settings.job.
中按计划配置了我的 Web 作业我在这里错过了什么?
你需要把你的逻辑放在Program.cs。
运行时间将通过执行可执行文件 运行 您的 WebJob,运行在 Program.cs 中使用 Main 方法。
如果您使用 settings.job 文件来安排您的 WebJob,您的逻辑应该放在 Program.cs 的 Main 函数中。如果你走这条路,你可以忽略 Functions.cs 文件。这对于将控制台应用程序迁移到 WebJob 并对其进行调度非常有用。
TimerTrigger 是一个 WebJob 扩展。它很有用,因为 Functions.cs 中可以有多个方法,每个方法都有一个按不同计划执行的单独 TimerTrigger。要使用这些,您的 WebJob 需要是连续的。
您似乎在函数定义中缺少 [FunctionName("TriggerProcess")] 属性,这就是您收到 "job not found" 错误的原因。