Azure Functions Debugging Timer and Http Trigger

Rick Maldonado 11 Reputation points
2021-09-28T04:14:22.737+00:00

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
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,298 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 20,101 Reputation points
    2021-09-29T08:12:04.257+00:00

    Hi @Rick Maldonado

    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.