我试着用TimerTrigger配置一个具有简单函数的作业。Azure Webjobs - 使用带定时器触发器的INameResolver函数
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" />
开始时我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();
}
当执行行host.RunAndBlock()
,我有这个例外:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法'ProcessMessages'---> System.FormatException:String未被识别为有效的TimeSpan。
我在实现INameResolver
接口的类中放了一个断点,但从未命中。
有什么办法用TimerTrigger配置NameResolver?
谢谢。
感谢马修,我已经创建了一个新的问题https://github.com/天青/蔚webjobs-SDK-扩展/问题/ 33。如果你能发布预发布,我将很乐意测试它。 – Thomas