Tho*_*mas 5 azure-webjobs azure-webjobssdk
我尝试使用 TimerTrigger 的简单功能配置作业。
public class Processor
{
/// <summary>
/// Initializes a new instance of the <see cref="Processor"/> class.
/// </summary>
public Processor()
{
}
/// <summary>
/// Process the Leads to Marketo.
/// </summary>
[Disable("Processor.Disable")]
public async Task ProcessMessages([TimerTrigger("%Processor.TimerTrigger%")] TimerInfo timerInfo, TextWriter log)
{
// TODO : remove
await Task.FromResult(0);
}
}
Run Code Online (Sandbox Code Playgroud)
我的设置在我的 app.config 文件中定义:
<add key="Processor.TimerTrigger" value="00:01:00" />
<add key="Processor.Disable" value="false" />
Run Code Online (Sandbox Code Playgroud)
启动我的 webjob 时,我已将作业配置为使用 INameResolver 和 timertrigger:
static void Main()
{
// Configure the job host
var config = new JobHostConfiguration
{
NameResolver = new ConfigNameResolver() // Resolve name from the config file.
};
config.UseTimers();
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Run Code Online (Sandbox Code Playgroud)
执行该行时host.RunAndBlock(),我遇到了以下异常:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法“ProcessMessages”---> System.FormatException:字符串未被识别为有效的时间跨度。
我在实现INameResolver接口但从未命中的类中放置了一个断点。
有没有办法用 TimerTrigger 配置 NameResolver ?
谢谢。
| 归档时间: |
|
| 查看次数: |
1686 次 |
| 最近记录: |