question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is TimeTrigger supported?

See original GitHub issue

Getting this error:

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ankitkumarrcommented, Jan 15, 2021

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.

1reaction
fabiocavcommented, Feb 26, 2021

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Timer trigger for Azure Functions
A timer trigger lets you run a function on a schedule. ... Support for this binding is automatically provided in all development ......
Read more >
Understanding TimerTriggers in Azure Functions
Multiple programming languages are supported e.g. C#, Javascript, Java to write your function. Multiple kinds of triggers are available.
Read more >
Azure Functions - Time Trigger (CRON) Cheat Sheet
Expression Description runs at 0 * * * * * every minute 09:00:00; 09:01:00; 09:02:00; … 10:00:00 0 */5 * * * * every 5...
Read more >
Visual Studio 2022 Create Azure TimeTrigger function ...
In the end I installed Visual Studio on another computer and it ran with no problems whatsoever.
Read more >
Debugging a background task on a time trigger - Windows Blog
The TimeTrigger class is extremely useful when your Universal Windows Platform (UWP) app has background tasks you want to run periodically.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found