Timespan.FromHours(24) not working after publish application on Azure app service

Rohan 0 Reputation points
2023-01-30T05:41:27.6566667+00:00

Hi i hi have one small simple application which logs the information. So I have one basic application which is using System.Threading.Timer and setup timer to run my function once a day and create logs. Ex. _timer = new Timer(callbackAsync, null, Timespan.Zero, Timespan.FromHours(24)); Now the problem is that on local when I run application from VS2022 it's working ok. But once I publish the application on Azure app service, it's misbehaving, executing my callbackAsync() in interval of 3-4 mins. I expect it to execute only once a everyday. So can you please help me here? Thanks, Rohan

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,374 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pritesh Patel 0 Reputation points
    2023-02-03T12:48:38.19+00:00

    yes, same issued happen with me

    I created one Ihostedservice using .NET CORE application, and setup to 10 min interval process

    Its working fine on local machine but when we deployed on Azure app service over there timer not worked on correct interval.

    My ref : https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-7.0&tabs=visual-studio#timed-background-tasks

    0 comments No comments