Error: Cannot bind parameter 'executionContext' to type ExecutionContext
Error: Cannot bind parameter 'executionContext' to type ExecutionContext
我有一个 .Net Framework 控制台应用程序,我可以在 Azure 中将其作为 WebJob 成功发布并查看它 运行ning。当我尝试将 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"]}");
}
我预计它会在 Azure 上 运行,没问题,根据 Documentation。我在 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.).
None 其中的内容确实有据可查,并且支持多个版本...我正在使用 2.x 版本的 WebJobs...
欢迎任何想法:)
您可以通过调用 config.UseCore()
注册它,之后您将能够使用 ExecutionContext
检索有关当前 运行 函数的信息。
更多信息,你可以参考这个文档:Core Extensions。下面是我的测试。
static void Main(string[] args)
{
var config = new JobHostConfiguration();
config.DashboardConnectionString = "connection";
config.UseTimers();
config.UseCore();
var host = new JobHost(config);
host.RunAndBlock();
}
我有一个 .Net Framework 控制台应用程序,我可以在 Azure 中将其作为 WebJob 成功发布并查看它 运行ning。当我尝试将 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"]}");
}
我预计它会在 Azure 上 运行,没问题,根据 Documentation。我在 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.).
None 其中的内容确实有据可查,并且支持多个版本...我正在使用 2.x 版本的 WebJobs...
欢迎任何想法:)
您可以通过调用 config.UseCore()
注册它,之后您将能够使用 ExecutionContext
检索有关当前 运行 函数的信息。
更多信息,你可以参考这个文档:Core Extensions。下面是我的测试。
static void Main(string[] args)
{
var config = new JobHostConfiguration();
config.DashboardConnectionString = "connection";
config.UseTimers();
config.UseCore();
var host = new JobHost(config);
host.RunAndBlock();
}