Azure webjobs Azure Webjobs-将Inamesolver与TimerTrigger函数一起使用
我试着用一个带有计时器的简单函数来配置一个作业Azure webjobs Azure Webjobs-将Inamesolver与TimerTrigger函数一起使用,azure-webjobs,azure-webjobssdk,Azure Webjobs,Azure Webjobssdk,我试着用一个带有计时器的简单函数来配置一个作业 public class Processor { /// <summary> /// Initializes a new instance of the <see cref="Processor"/> class. /// </summary> public Processor() { } /// <summary> /// Proc
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);
}
}
在执行host.RunAndBlock()行时,我遇到了以下异常:
Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException:错误索引方法“ProcessMessages”-->System.FormatException:未将字符串识别为有效的时间跨度
我已经在类中设置了一个断点,该类实现了INameResolver
接口,但从未命中
有没有办法用TimerTrigger配置名称解析器
谢谢。TimerTrigger目前不支持INameResolver。请在公共回购中打开一个问题,我们将添加该支持。其他扩展绑定支持
INameResolver
。如果这对您很重要,我们可以在实际的下一个版本之前为您提供一个供您使用/验证的解决方案。使用原始问题中的技术和如下所示的解析器,确认INameResolver现在在计时器触发器中受支持:
public class ConfigNameResolver : INameResolver
{
public string Resolve(string name)
{
return ConfigurationManager.AppSettings.Get(name);
}
}
谢谢马修,我创造了一个新的问题。如果你能推出一个预发行版,我会很高兴测试它。
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();
}
public class ConfigNameResolver : INameResolver
{
public string Resolve(string name)
{
return ConfigurationManager.AppSettings.Get(name);
}
}