question

RickMaldonado-4688 avatar image
0 Votes"
RickMaldonado-4688 asked AnuragSingh-MSFT edited

Azure Functions Debugging Timer and Http Trigger

I have my timer function run on startup (debugging purposes). As the timer function is running I cannot hit my HTTP trigger functions.

It seems the timer function was blocking thread. So made it async function but same effect.

 [FunctionName("GetPendingTwilioMsgs")]    
     public static async Task Run([TimerTrigger("0 30 9 * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log)
     {            
         await Task.Run(async () =>
         {
             await Task.Delay(30000);                
         });
 }

Any ideas what is going on?

Shouldn't the HTTP trigger functions work regardless of timer function running?

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered AnuragSingh-MSFT edited

Hi @RickMaldonado-4688

Welcome to Microsoft Q&A!

This is a known issue, and a fix is underway. The cause of the issue is mentioned here as - The issue is WebScriptHostService is an IHostedService, and as part of startup, it starts the ScriptHost, which starts all the listeners. The app can't start processing http requests until all the hosted services are started up. So, the fact that WebScriptHostService awaits host/listener startup here means http requests can't be processed until that's complete. That means that http requests weren't processed until the 30s startup timer (as configured in TimerTrigger function with 30s delay in this case) invocation completed. You can get more details about the issue on this link.

I tested out with the current version (without the fix) and noticed that this behavior only applies to the initial run of timerTrigger function with RunOnStartup=true. Once the host is initialized, the subsequent runs are in parallel.

Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RickMaldonado-4688, I wanted to check if you had a chance to review my answer above. Please let me know if you have any queries or concerns.
Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·