0

I deploy an Azure Function precompiled with a timerTrigger. I have the following exception when I activate all logs

2017-04-13T12:53:03.836 {"id":"b91045c2-ff21-4c9d-bd14-88e90723adbe","requestId":"37212a13-73ae-4e1e-9f1e-130f3865e258","statusCode":500,"errorCode":0,"messsage":"Sequence contains no matching element"} 2017-04-13T12:53:03.836 System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate) at Microsoft.Azure.WebJobs.Script.WebHost.Controllers.AdminController.Invoke(String name, FunctionInvocation invocation) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown ---

My function.json

{
  "scriptFile": "..\\bin\\Plop.Statistics.dll",
  "entryPoint": "Plop.Statistics.S4BStatisticsCommand.Function.Run",
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */1 * * * *"
    },
    {
      "name": "outputQueueItem",
      "queueName": "command-queue",
      "type": "queue",
      "direction": "out",
      "connection": "AzureWebJobsStorage"
    }
  ],
  "disabled": false
}

and my function

namespace Plop.Statistics.S4BStatisticsCommand{
public class Function
{
    public static async Task Run(TimerInfo myTimer, ICollector<S4BStatisticCommand> outputQueueItem, TraceWriter log)
    {
       log.Info("hello");
    }

Thanks for your help!

EDIT:

The timerTrigger is not triggered because the function is not found. Here the logs:

2017-04-14T08:54:11.773 File change of type 'Created' detected for:\home\site\wwwroot\S4BStatisticsCommand'

2017-04-14T08:54:11.773 Host configuration has changed. Signaling restart

2017-04-14T08:54:12.167 File change of type 'Created' detected for 'D:\home\site\wwwroot\S4BStatisticsCommand\function.json'

2017-04-14T08:54:12.167 Host configuration has changed. Signaling restart

2017-04-14T08:54:12.281 File change of type 'Changed' detected for 'D:\home\site\wwwroot\S4BStatisticsCommand\function.json'

2017-04-14T08:54:12.281 Host configuration has changed. Signaling restart

2017-04-14T08:54:12.785 Stopping Host

2017-04-14T08:54:12.832 Job host stopped

2017-04-14T08:54:12.894 Host instance 'f3bf62b4fcd9d52410e4b055937d68db' released lock lease.

2017-04-14T08:54:12.957 Reading host configuration file 'D:\home\site\wwwroot\host.json'

2017-04-14T08:54:13.317 Host lock lease acquired by instance ID 'f3bf62b4fcd9d52410e4b055937d68db'.

2017-04-14T08:54:14.070 Generating 1 job function(s)

2017-04-14T08:54:14.097 Starting Host (HostId=4ab0f60d5dc84308a2fd847b978c468b, Version=1.0.10841.0, ProcessId=8628, Debug=True, Attempt=0)

2017-04-14T08:54:14.113 Development settings applied

2017-04-14T08:54:14.113 No job functions found. Try making your job classes and methods public. 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.).

2017-04-14T08:54:14.113 Job host started

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
Nico
  • 153
  • 9
  • Your run function is truncated – Matt Evans Apr 13 '17 at 13:05
  • nothing special in it – Nico Apr 13 '17 at 13:18
  • is the Cron definition valid? http://cron.schlitt.info – Matt Evans Apr 13 '17 at 13:28
  • Yes ! I tried many different. But the expcetion is in Microsoft.Azure.WebJobs.Script.WebHost.Controllers.AdminController.Invoke – Nico Apr 13 '17 at 13:33
  • What versions of `Microsoft.Azure.WebJobs` nugets are you using in your precompiled function? Also, this particular error appears to occur when you run manually from the portal - do you also see the error if the timer trigger runs organically? – Matt Mason Apr 13 '17 at 17:01
  • Yes, I have this error when I run manually. The WebJob SDK is "Microsoft.Azure.WebJobs" versio 2.0.0 targetting net461. I don't see any logs when the timer trigger should run... – Nico Apr 14 '17 at 08:42
  • The timerTrigger is not triggered becaus the function is not found. Here the log – Nico Apr 14 '17 at 09:08

2 Answers2

1

Timer Triggers require the Microsoft.Azure.WebJobs.Extensions nuget, the job host should register your function.

See this precompiled function article, specifically the 'converting to class files' section.

  1. If you’re using timer triggers, add the NuGet package Microsoft.Azure.WebJobs.Extensions.
Matt Mason
  • 2,676
  • 9
  • 22
1

I have a timer trigger working on a precompiled function using a slightly different definition of the Run function.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;

namespace PrecompiledDLL
{
    public partial class PrecompiledFunction
    {
        public static async Task Run(TimerInfo myTimer, TraceWriter log)
        {
            log.Info("Hello World");
        }
    }
}
user1623237
  • 223
  • 2
  • 6