我有一个.Net Framework控制台应用程序,可以将其成功发布为Azure中的WebJob并看到它正在运行。当我尝试向函数添加ExecutionContext参数时,我收到上述错误消息(无论参数的位置如何)。
我尝试将参数移动到方法签名中的每个位置。每次都有相同的错误。
Startup.cs
var config = new JobHostConfiguration
{
JobActivator = new AuditorSyncActivator(serviceProvider)
};
// Setting the value of connection limit to that which the Sandbox would impose
// which should be sufficient for the application going forward, given demand.
ServicePointManager.DefaultConnectionLimit = 300;
// We are using an NCRONTAB expression to run the function on a schedule
config.UseTimers();
var host = new JobHost(config);
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
Functions.cs
[FunctionName("AuditorSync")]
public void ProcessQueueMessage(
[TimerTrigger("0 */5 * * * *", RunOnStartup = false)] TimerInfo timer,
ExecutionContext executionContext,
Microsoft.Extensions.Logging.ILogger logger)
{
if (timer.IsPastDue)
{
_logger.Warning("Timer is running late");
}
_logger.Information($"WebJob Function Execution: Id={executionContext.InvocationId}, Action={_config.GetSection("AuditorSyncOptions")["Action"]}");
}
根据Documentation,我希望它可以在Azure上运行,没有问题。我在Azure上的日志中得到的是
[08/27/2019 22:28:03 > e3a876: ERR ] Unhandled Exception: Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException: Error indexing method 'Functions.ProcessQueueMessage' ---> System.InvalidOperationException: Cannot bind parameter 'executionContext' to type ExecutionContext. Make sure the parameter Type is supported by the binding. 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.).
所有这些文档都没有得到很好的记录,并且支持多个版本...我正在使用WebJobs的2.x版本...
欢迎任何想法:)
答案 0 :(得分:0)
此后,您可以通过调用(0, '0.020*"business" + 0.018*"data" + 0.012*"experience" + 0.010*"learning" + 0.008*"analytics"')
(1, '0.027*"data" + 0.020*"experience" + 0.013*"business" + 0.010*"role" + 0.009*"science"')
(2, '0.026*"data" + 0.016*"experience" + 0.012*"learning" + 0.011*"machine" + 0.009*"business"')
(3, '0.028*"data" + 0.015*"analytics" + 0.015*"experience" + 0.008*"business" + 0.008*"skills"')
(4, '0.014*"data" + 0.009*"learning" + 0.009*"machine" + 0.009*"business" + 0.008*"experience"')
[
['business', 'data', 'experience', 'learning', 'analytics'],
['data', 'experience', 'business', 'role', 'science'],
['data', 'experience', 'learning', 'machine', 'business'],
['data', 'analytics', 'experience', 'business', 'skills'],
['data', 'learning', 'machine', 'business', 'experience']
]
进行注册,这样您就可以使用config.UseCore()
来检索有关当前正在运行的功能的信息。
更多信息,您可以参考以下文档:Core Extensions。以下是我的测试。
ExecutionContext