【发布时间】:2016-05-09 09:13:10
【问题描述】:
我尝试用 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);
}
}
我的设置在我的 app.config 文件中定义:
<add key="Processor.TimerTrigger" value="00:01:00" />
<add key="Processor.Disable" value="false" />
开始我的网络作业时,我已将作业配置为使用 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();
}
在执行host.RunAndBlock() 行时,我遇到了这个异常:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法“ProcessMessages”---> System.FormatException:字符串未被识别为有效的 TimeSpan。
我在实现INameResolver 接口但从未命中的类中设置了一个断点。
有什么方法可以用 TimerTrigger 配置 NameResolver 吗?
谢谢。
【问题讨论】:
标签: azure-webjobs azure-webjobssdk