I have a .Net Framework console application that I can successfully publish as a WebJob in Azure and see it running. When I try to add an ExecutionContext parameter to my function, I receive the above error message (regardless of the position of the parameter).
I've tried moving the parameter to each position in the method signature. Same error each time.
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"]}");
}
I expected it to run on Azure, no problem, according to the Documentation. What I got in the logs on Azure was
[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 of this is really all that well documented, and there are several versions being supported... I'm using the 2.x version of WebJobs...
Any ideas are welcomed :)
You could register it with calling config.UseCore()
after this you will be able to use ExecutionContext
to retrieve information about the currently running function.
Further more information, you could refer to this doc:Core Extensions. Below is my test.
static void Main(string[] args)
{
var config = new JobHostConfiguration();
config.DashboardConnectionString = "connection";
config.UseTimers();
config.UseCore();
var host = new JobHost(config);
host.RunAndBlock();
}