Azure / Azure-Functions

1.1k stars 189 forks source link

Custom Handlers - Graceful shutdown/SIGTERM #2490

Open KarlGW opened 1 month ago

KarlGW commented 1 month ago

Hello!

There doesn't seem to be any documentation on how Azure Functions with Custom Handlers handles (or provides functionality) for SIGTERM and in extension the possibility for graceful shutdowns. I've looked through old and other issues regarding this, but none of them (that I could find) is about how it is handled with custom handlers.

I've tried to enable signal handling within my application written in Go (and it works locally). But running it through func, only tests with simple logging works. Adding additional work will just make the process exit. The same result with the application deployed to a function app (both Windows and Linux based function apps on a consumption plan), with the difference that the "shutdown" logs aren't shown at all in application insights when the function app "scales down to 0"/shuts down.

This raises the following questions:

  1. Is it supported?
  2. If it is, how is it handled properly?
  3. What are the timeouts?
  4. Can these be configured?

Best regards