Azure function time out for c#

Roy, Chandan 0 Reputation points
2023-02-22T06:07:32.6266667+00:00

Need to set the timeout for Azure function using c#. I have put timeout in host.json but it is not working.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sander van de Velde | MVP 36,761 Reputation points MVP Volunteer Moderator
    2023-02-22T20:08:25.0766667+00:00

    Hello @Roy, Chandan,

    Azure Functions run for a certain time, depending on the plan:

    User's image

    The host setting should help you for now.

    I recommend rethinking your architecture if you 'run out of time' and search for the bottleneck.

    Extra, regarding the dedicated plan, you need to set a few things:

    • Set the 'always on' setting
    • Set the alternative timeout

    You can set the timeout in the host.json file:

    {
        ... 
        ,
        "functionTimeout": "00:55:00"
    }
    

    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.

    0 comments No comments

  2. MughundhanRaveendran-MSFT 12,506 Reputation points
    2023-02-24T05:00:52.4+00:00

    @Roy, Chandan

    As mentioned by @Sander van de Velde If your Http trigger function is taking longer than 230 sceconds to respond, the function will time out irrespective of the timeout value that is set in the Host.json file. This 230 second timeout is the Http trigger load balancer timeout. Please see the below post for an explanation about this timeout.

    https://learn.microsoft.com/en-us/answers/questions/758823/httptrigger-response-timeout

    To overcome this you will have to use the Durable function where the client would get a 202 response immediately from the Azure function. The function will provide 202 to the client and it will continue to execute even exceeding 230 seconds.

    Please let me know if your function is timing out even before 230 seconds. I hope that is not the case.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.