0
votes

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

2
Your run function is truncatedMatt Evans
nothing special in itNico
is the Cron definition valid? cron.schlitt.infoMatt Evans
Yes ! I tried many different. But the expcetion is in Microsoft.Azure.WebJobs.Script.WebHost.Controllers.AdminController.InvokeNico
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

2 Answers

1
votes

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.
1
votes

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");
        }
    }
}