azure-functions-dotnet-worker: Is TimeTrigger supported?

Getting this error:

The 'XXX' function is in error: Can't figure out which ctor to call.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 24 (9 by maintainers)

Most upvoted comments

Hi, I apologize for the delay here. As you may have read from our announcement – because .NET 5 functions run as an out-of-proc execution model, “rich” types that were available in the inproc model for .NET 3 and lower are not supported out of the box yet.

In this case, that’s why TimerInfo isn’t working out of the box. We could look into add some converter to at least support this type temporarily (cc: @brettsam @fabiocav).

However, you could also create a POCO with the required properties and use that instead of TimerInfo in your function parameter. Here’s an example –

public class MyInfo
{
    public MyScheduleStatus ScheduleStatus { get; set; }

    /// <summary>
    /// Gets a value indicating whether this timer invocation
    /// is due to a missed schedule occurrence.
    /// </summary>
    public bool IsPastDue { get; set; }
}

public class MyScheduleStatus
{
    /// <summary>
    /// Gets or sets the last recorded schedule occurrence.
    /// </summary>
    public DateTime Last { get; set; }

    /// <summary>
    /// Gets or sets the expected next schedule occurrence.
    /// </summary>
    public DateTime Next { get; set; }

    /// <summary>
    /// Gets or sets the last time this record was updated. This is used to re-calculate Next
    /// with the current Schedule after a host restart.
    /// </summary>
    public DateTime LastUpdated { get; set; }
}

And then you can define your function like –

[FunctionName("Function6")]
public static void Run([TimerTrigger("0 */1 * * * *")] MyInfo myTimer,
    FunctionExecutionContext executionContext)
{
    var logger = executionContext.Logger;
    logger.LogInformation($"message logged {myTimer.ScheduleStatus.Next} ");
}

@dmytro-gokun, that’s a good idea. We will add an example in this repo for TimerTrigger shortly.

@dmytro-gokun I’m sorry you’re getting that impression, but I can assure you that isn’t the case. I’m transferring this issue to the Worker repo where you can track the activity, releases and announcements.

The original issue should be addressed in the latest previews and you can see a collection of samples (including timer) here: https://github.com/Azure/azure-functions-dotnet-worker/tree/main/samples/SampleApp

@fabiocav I’m not sure why you talking about App Service here. What i have is a Function using Consumption Plan. When I create that, I do not have any way to select “.NET”:

image

Furthermore, after it’s created, i do not have any means to change to edit “Stack Settings”.

image

May be i have to enable some “early access” settings on the Portal to be able to do that?

@dmytro-gokun, we released 1.0.0-preview2 versions of the Microsoft.Azure.Functions.Worker.Sdk and Microsoft.Azure.Functions.Worker yesterday in Nuget including the fix for TimerTrigger. Please try using that!

I can confirm I am having the same issue.