Home > Mobile >  TimeoutAttribute doesn't work for Azure function app
TimeoutAttribute doesn't work for Azure function app

Time:10-27

I'd like to limit the execution time of the azure function, and added the TimeoutAttribute on it as the code below.

    [FunctionName("Func2")]
    [Timeout("00:00:02", TimeoutWhileDebugging = true)]
    public static void Run([TimerTrigger("*/5 * * * * *")] TimerInfo myTimer, ILogger log)
    {
        log.LogInformation($"hi...");

        int length = 10;
        for (int i = 0; i < length; i  )
        {
            log.LogInformation($"looping {i   1}...");
            //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
            System.Threading.Tasks.Task.Delay(3000).Wait();
        }
    }

I ran the code in visual studio 2019 locally. And I expected the above code times out in 2 seconds, but it ran the complete 10 loops without any error.

Is there any issue above?

CodePudding user response:

This is looking like a bug and reproducible, I can also reproduce this locally

Github issues #1900

At the moment this is progressing through triage and has the Bug tag.

Note : At this stage there are no known workarounds

  • Related