Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 440 forks source link

Timer trigger functions not invoking after migrating to .NET 8 isolated for Linux Consumption plans #9750

Closed sanjaybhagia closed 8 months ago

sanjaybhagia commented 8 months ago

Azure functions are running on a Linux Consumption plan with .NET 6 Isolated and working fine. In the function app, there is a timer trigger function that executes every hour, and it contains other functions, which are Service Bus and Event Hub Trigger-based.

I have migrated the function to .Net 8 Isolated now. After the deployment, the function doesn't work. The timer trigger function is not invoked. If I manually browse the function from Azure Portal, it comes back, works for some time, and eventually dies down.

Points to highlight:

The function app does not contain any active trigger warnings detected during this period.(see image attached) image

Investigative information

Please provide the following:

Expected behavior

The timer trigger function should invoke every hour based on the set schedule (cron).

image#### Actual behavior

Provide a description of the actual behavior observed.

image

Known workarounds

Navigating the function from Azure Portal triggers the functions for some time.

Related information

Provide any related information

kshyju commented 8 months ago

@sanjaybhagia

  1. Does your timer trigger work when running/debugging locally?
  2. Where are you defining your cron expression for the timer trigger?
  3. Can you share your timer trigger method signature?
sanjaybhagia commented 8 months ago
  1. Does your timer trigger work when running/debugging locally? Yes, works fine locally and running on .net 6 isolated
  2. Where are you defining your cron expression for the timer trigger? App Settings (expression: 0 0 )
  3. Can you share your timer trigger method signature? [Function(nameof(DataTrigger))] public async Task Run([TimerTrigger("%data_trigger_timer%", RunOnStartup = false)] TimerInfo myTimer) { // removed }
kshyju commented 8 months ago

@sanjaybhagia Does restarting your app work? If not, I recommend opening a support ticket for deeper investigation of your app.

sanjaybhagia commented 8 months ago

No, restarting doesn't help with this.

kshyju commented 8 months ago

Please open a support ticket so that the team can take a deeper look at your application. Thanks!

silvacaio commented 7 months ago

Any update about that issue @kshyju ? We are facing the same problem with a function that have a Service Bus trigger.

Morras commented 7 months ago

I might have a solution to this problem.

My function would start correctly when deployed and fire any triggers that was overdue, but according to the logs, after 20 minutes the Job host would be stopped and never start up again.

If I restarted the function app the Job host would start and run any past due triggers, but again it would stop after 20 minutes.

After struggling through MS support (TrackingID#2312140050000795 if anyone from MS is interested) since mid december with this, I finally caught a break last week.

I used Microsoft.Azure.Functions.Worker.Sdk version 1.16.3 but if I downgraded that to Microsoft.Azure.Functions.Worker.Sdk version 1.15.1 then it worked.

This was on .NET 7, in an isolated Windows consumption plan, so a slightly different setup than the original post, however the SDK version numbers are similar.

sanjaybhagia commented 7 months ago

This is parsing related issue (https://github.com/Azure/azure-functions-dotnet-worker/pull/2234) and has been resolved. Please use Microsoft.Azure.Functions.Worker.Sdk 1.17.0-preview1 or higher.

kolexinfos commented 5 months ago

I am running into the same issue where Timer-Triggered functions are not firing in .Net 8 and Isolated mode and I have updated all my packages as shown below but still the triggers does not fire when deployed in Azure using az deploy with zip.

I am wondering if there is a mismatch in Function Core tools(func), what is the version of the Azure Runtime that your Function App is using in Azure.

The triggers fire locally and my func version locally is 4.0.5455.

    <PackageVersion Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.DurableTask" Version="1.0.2" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.OpenApi" Version="1.5.1" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.13.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.EventHubs" Version="6.1.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
    <PackageVersion Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
danelec-hpm commented 3 months ago

Make sure you have a local.settings.json file in the root of your function project. The content should look like this: { "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } }

Adding this file worked for me. Apparently this file was not needed in previous dotnet versions to run locally or some developer forgot to commit it to the repository.