Durable Functions - infinite execution with state doesn't work

Viewed 673

I'm setting up a durable Function that should run infinitely with by invoking itself every hour and keeping a state. The function compiles, bus fails at run with the following error:

2017-07-12T07:04:05.614 Exception while executing function: Functions.DurableTimer. Microsoft.Azure.WebJobs.Host: Exception binding parameter 'context'. Microsoft.Azure.WebJobs.Extensions.DurableTask: Cannot convert to DurableOrchestrationContext.

Function code

#r "Microsoft.Azure.WebJobs.Extensions.DurableTask"

using System;
using System.Threading;

public static async Task Run(DurableOrchestrationContext context, TraceWriter log)
{
    log.Info($"Durable function executed at: {context.CurrentUtcDateTime}");

    // sleep for one hour between calls
    DateTime nextExecution = context.CurrentUtcDateTime.AddHours(1);
    await context.CreateTimer(nextExecution, CancellationToken.None);

    int counterState = context.GetInput<int>();
    log.Info($"Counter state: {counterState}");

    counterState++;

    context.ContinueAsNew(counterState); 
}

function.json

{
  "bindings": [
    {
      "name": "context",
      "type": "orchestrationTrigger",
      "direction": "in"
    }
  ],
  "disabled": false
}
1 Answers
Related