Why do I See "DrainMode mode enabled" in the logs and then all timer trigger functions stop ?

Florent Bonamis 26 Reputation points
2022-03-14T09:10:22.163+00:00

Why can I see "DrainMode mode enabled" in the logs and then the the time trigger jobs are stopping?
I have 4 functions

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

2 answers

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-03-14T15:36:28.157+00:00

    @Florent Bonamis ,

    Thanks for reaching out to Q&A.

    For Azure functions running on consumption and elastic premium plan (serverless), the scale controller decides the scaling behavior. Drain mode comes into picture when the scale controller decides to scale down a worker (during less load). At this time, it sends a request to the Admin API to enter drain mode. Then all currently executing Functions on that instance receive a cancellation token which the customer can handle.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library?tabs=v2%2Ccmd#cancellation-tokens

    Then once all currently executing invocations have stopped then we will stop all of the listeners to ensure that the worker is shutting down doesn’t handle any new invocations. There’s no way to avoid the cancellation tokens.

    However, timer triggers operate based on cron schedule and there is no scale controller involvement. The drain mode doesnt seem to have caused the functions to stop. I would suggest you to look into the Diagnose and solve problems blade and run the "Function app down or reporting errors" detector during the time the issue was seen. This detector will help you identify what caused the function host to go down.

    I hope this helps! Feel free to reach out to me if you have any queries or concerns.

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

    2 people found this answer helpful.

  2. Dyt13 211 Reputation points
    2022-10-19T07:51:17.097+00:00

    Hello, @Florent Bonamis did you get an answer by any chance from microsoft @MughundhanRaveendran-MSFT ? I have an open ticket as well with the support for the same prb. The diagnosis didn't provide help. My use case is similar : time triggered functions that stop for no reason

    0 comments No comments

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.