Function App termination during deployment

Sourav 185 Reputation points
2023-12-11T04:07:02.8833333+00:00

My executing function app is getting terminated when I deploy a new version.
As per documentation it is the intended behavior: https://learn.microsoft.com/en-us/azure/azure-functions/functions-deployment-technologies?tabs=windows#deployment-behaviors

Is there a way, so that my running function app can finish it's execution?

I'm trying to handle this situation using CancellationToken. But, it's triggering only for timeout, not when we are deploying the function.

Any suggestion to mitigate this would be very helpful.

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

Accepted answer
  1. Ben Gimblett 4,555 Reputation points Microsoft Employee
    2023-12-12T09:40:15.15+00:00

    From memory IIS signals through events in the web handler that ultimately sits under the execution pipeline. On linux it would be via Signals e.g. SIGTERM

    So the underlying mechanism is going to differ between windows hosting and linux hosting

    It wouldn't make sense to allow user code to block an app shutdown - the OS can always force this. I am not aware of a way you could override it.

    In terms of best practice, you should really code the function to be as short running as reasonably possible (this for efficinecy) but most important the function should be written to be idempotent and without-side-effect. Meaning; the function can be run multiple times for the same input without causing problems with data (duplication, corruption) or any other side effect to other components. This is important because functions need to be able to handle transient faults as well as scale down events etc.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-best-practices?tabs=csharp#write-robust-functions

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.