Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is TimeTrigger supported? #185

Closed
dmytro-gokun opened this issue Dec 11, 2020 · 24 comments
Closed

Is TimeTrigger supported? #185

dmytro-gokun opened this issue Dec 11, 2020 · 24 comments

Comments

@dmytro-gokun
Copy link

Getting this error:

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

I can confirm I am having the same issue.

@ankitkumarr
Copy link
Contributor

Thanks for reporting this. We were able to repro this. Our binding metadata generation from the Function attributes has some mismatches.
We have put a fix in place for Timer trigger and will be releasing updated packages soon.

@SeanFeldman
Copy link
Contributor

Would be nice to consolidate information here with Azure/azure-functions-dotnet-worker-preview#14

@dmytro-gokun
Copy link
Author

@ankitkumarr Has anything been released to fix this issue?

@ankitkumarr
Copy link
Contributor

@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!

@gabrielbaptista
Copy link

@ankitkumarr , the trigger is happing now, but I got this error:
[2021-01-08T03:25:20.012Z] Executing 'Functions.TimerTriggerFunction' (Reason='Timer fired at 2021-01-08T00:25:20.0115789-03:00', Id=065d5b8f-7f2c-4d68-8ab9-5fdffde7c7cb)
[2021-01-08T03:25:20.024Z] Executed 'Functions.TimerTriggerFunction' (Failed, Id=065d5b8f-7f2c-4d68-8ab9-5fdffde7c7cb, Duration=10ms)
[2021-01-08T03:25:20.028Z] System.Private.CoreLib: Exception while executing function: Functions.TimerTriggerFunction. System.Private.CoreLib: Result: Failure
Exception: Unable to convert to Microsoft.Azure.WebJobs.TimerInfo
Stack: at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ConvertParameter(ParameterInfo param, TypedData value, ParameterConverterManager converterManager) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 117

@AKomyshan
Copy link

AKomyshan commented Jan 9, 2021

I get the same error

[2021-01-09T05:19:00.014Z] Executing 'Functions.Timer01' (Reason='Timer fired at 2021-01-09T07:19:00.0129108+02:00', Id=beeb41df-e734-44fe-993e-30be57921bd4)
[2021-01-09T05:19:00.078Z] Executed 'Functions.Timer01' (Failed, Id=beeb41df-e734-44fe-993e-30be57921bd4, Duration=64ms)
[2021-01-09T05:19:00.085Z] System.Private.CoreLib: Exception while executing function: Functions.Timer01. System.Private.CoreLib: Result: Failure
Exception: Unable to convert to Microsoft.Azure.WebJobs.TimerInfo
Stack:    at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ConvertParameter(ParameterInfo param, TypedData value, ParameterConverterManager converterManager) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 117
[2021-01-09T05:19:00.086Z]    at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionExecutionContext context) in D:\a\1\s\src\DotNetWorker\Invocation\DefaultFunctionExecutor.cs:line 60
[2021-01-09T05:19:00.088Z]    at Microsoft.Azure.Functions.Worker.FunctionBroker.InvokeAsync(InvocationRequest invocationRequest) in D:\a\1\s\src\DotNetWorker\Broker\FunctionBroker.cs:line 44.

@dmytro-gokun
Copy link
Author

@ankitkumarr I'm getting the same error as other guys. Is there any workaround for that? Here's what I'm refrencing:

  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.2" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.3" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.0-preview2" OutputItemType="Analyzer"/>
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.0.0-preview2" />
  </ItemGroup>

@dmytro-gokun
Copy link
Author

@ankitkumarr Actually, would not it be nice if there were a TimeTrigger example in this repository? Then it would be easier for people to see how to use it and you will be able to test it quickly if something did not work :)

@ankitkumarr
Copy link
Contributor

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
Copy link
Author

dmytro-gokun commented Jan 15, 2021

@ankitkumarr Thanks for the update. Finally, I was able to run this function locally. However, it still would not run on Azure:

The framework 'Microsoft.NETCore.App', version '5.0.0' was not found

and this is expected as I'm running on consumption plan which does not seem to have .NET 5.0 installed. Am I missing something here?

@fabiocav
Copy link
Member

@dmytro-gokun are you still experiencing issues in Azure? Have you followed the configuration information instructions here?

@dmytro-gokun
Copy link
Author

@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?

@aaronzhongg
Copy link

@dmytro-gokun hey just following up to see whether you have resolved the issue running the function app on Azure?

@dmytro-gokun
Copy link
Author

@azho472 I've decided not to waste time on it anymore and wait for it to be released. Obviously, these "previews" are very low priority with MS and they do not care to allocate any serious resources to fix all these issues or at least comment here.

@fabiocav
Copy link
Member

@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
Copy link
Member

Also, reading through the thread and for clarity, Functions runs on App Service (consumption and dedicated/app service plans) . The link I provided applies to both models and enables .NET 5 for the site.

@fabiocav fabiocav transferred this issue from Azure/azure-functions-dotnet-worker-preview Feb 26, 2021
@dmytro-gokun
Copy link
Author

@fabiocav Thanks for the update.

Functions runs on App Service (consumption and dedicated/app service plans).

Please check the screenshot above. When using Consumption App Service Plan you do NOT have "Stack settings" under "Configuration" -> "General settings". That is the problem and that's why I asked if I needed to enable something on the portal so see that. I've now re-read the article at the link you've posted and I do not see anything like that. It just claims that .NET 5 should be available already. And it is, but only when using a dedicated App Service Plan. So, i'm still left in the limbo here. I am willing to give this preview one more try, but I cannot since all our functions use Consumption Plan. Any advice?

@sccrgoalie1
Copy link

I'm having trouble getting my TimerTriggers working on Azure as well. I have a service bus trigger that works fine, but the timers aren't firing. We are running on the premium plan, so don't have an explicit option to change to .NET 5, but if that was the problem wouldn't the service bus trigger fail as well?

I just updated to preview 5 today hoping that would work, but no such luck.

@dmytro-gokun
Copy link
Author

@fabiocav Any chance you can help with this issue. Or is it's just we should accept that this out of process thing does not work with Consumption Plans and wait for .NET 6 (or 7?). I'm totally confused.

@sccrgoalie1
Copy link

I got it working after I found this error. In the past this setting had always been there in the portal, but was missing. I set the AzureWebJobsStorage configuration setting and then it started working.

image

@brettsam
Copy link
Member

@sccrgoalie1 -- do you know how you created your app? Missing that storage setting would cause some issues so we should try to prevent it wherever we can.

@sccrgoalie1
Copy link

@sccrgoalie1 -- do you know how you created your app? Missing that storage setting would cause some issues so we should try to prevent it wherever we can.

I believe I added a slot in the Azure portal and then deployed as described in the readme

@fabiocav
Copy link
Member

Closing this issue as it looks like all questions/issues have been addressed.

If there are any remaining questions, please feel free to open a new issue.

Thank you, all!

@ghost ghost locked as resolved and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants