Azure / azure-webjobs-sdk

Azure WebJobs SDK
MIT License
738 stars 358 forks source link

TimerTrigger webjobs get "corrupted" without apparent reason #975

Closed navaldroid closed 7 years ago

navaldroid commented 7 years ago

Hello, I'm using version 2.0.0-beta2 of WebJobs.Extensions.

I need a dynamic job schedule with syntax "%cron_expr%" in TimerTrigger attribute, which is not yet possible with the latest stable release.

Unexpectedly, after some non-structural code changes to my project, I get a Microsoft.Azure.WebJobs.Host.FunctionInvocationException.

InnerException seems to be a System.TypeLoadException due to failed loading the implementation for method ValueProvider.GetValueAsync at Microsoft.Azure.WebJobs.Extensions.Timers.Bindings.TimerTriggerBinding.

I'm using Visual Studio 2015 with VSTS over Git and continuous deployment.

Here's my Main() in Program.cs:


static void Main() { var config = new JobHostConfiguration { NameResolver = new DreddNameResolver() }; if (config.IsDevelopment) { config.UseDevelopmentSettings(); } config.UseTimers(); var host = new JobHost(config); host.RunAndBlock(); }


Here's my web job:

public static void MyWebJob([TimerTrigger("%cron_expr%", RunOnStartup = true)] TimerInfo info, [Queue("myqueue")] ICollector outputQueueMessage, TextWriter logger) { try { // My code... } catch (Exception e) { // Exception handling }


My INameResolver is simply:

public class DreddNameResolver : INameResolver
{
    public string Resolve(string name)
    {
        // return my cron expression here
    }
}

Here's the exception log in Kudu workspace:

Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.MyWebJob ---> System.InvalidOperationException: Exception binding parameter 'info' ---> System.TypeLoadException: Method 'GetValueAsync' in type 'ValueProvider' from assembly 'Microsoft.Azure.WebJobs.Extensions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation. at Microsoft.Azure.WebJobs.Extensions.Timers.Bindings.TimerTriggerBinding.d12.MoveNext() at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine& stateMachine) at Microsoft.Azure.WebJobs.Extensions.Timers.Bindings.TimerTriggerBinding.BindAsync(Object value, ValueBindingContext context) at Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding1.d8.MoveNext() --- End of inner exception stack trace --- at Microsoft.Azure.WebJobs.Host.Executors.DelayedException.Throw() at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.

d__13.MoveNext() --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor. d__13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.d__10.MoveNext() [EOF]
brettsam commented 7 years ago

What version of the WebJobs nuget package are you using? We just put out an update to Extensions to sync with an API change we made to take GetValue -> GetValueAsync. I suspect that if you update your Extensions package to the newest (https://www.myget.org/feed/azure-appservice/package/nuget/Microsoft.Azure.WebJobs.Extensions), it'll work.

navaldroid commented 7 years ago

This is a light-fast answer! I've completely rebuilt and redeployed the project and now it works (I had to do it already once in the past). I think we can close the issue; I will reopen it in case. Thanks!