An Azure service that provides an event-driven serverless compute platform.
What you are experiencing appears to be related to how Azure Functions manages timer triggers. Timer triggers in a function app rely not only on the code in your deployment but also on state stored in the Azure Storage account associated with the function app. Specifically, the runtime uses a hidden mechanism to persist schedules and "next run" information in the azure-webjobs-hosts container under the timers folder. This allows the runtime to track when timers should fire, even across restarts or redeployments. If a timer function is removed from your code but the corresponding state in the storage account remains, the runtime can still read the persisted schedule and execute the function, attempting to honor the last known configuration. Essentially, the runtime doesn’t automatically delete this state when the code is removed, which is why a deleted timer can run unexpectedly.
The code being executed comes from the version of the function binaries currently deployed in the function app's wwwroot. If your deployment process involves uploading new binaries after Terraform completes the apply phase, there can be a brief window where the runtime still has the old binaries in memory or on disk while it reads the timer metadata from storage. This explains why the deleted timer ran: the host read its schedule from storage before your latest binaries replaced the previous ones, so it executed the old code.
Deleting the corresponding timer metadata file in Blob containers -> azure-webjobs-hosts -> timers -> <your function name> -> Host.Functions.<trigger name> does stop the runtime from scheduling that specific timer. The runtime uses this file to determine the next run, so removing it effectively clears the timer’s schedule. You need to be aware, though, that simply deleting the file won’t prevent execution if there are still cached binaries in memory during deployment; this is mainly a safeguard against persisting schedules for removed timers. In practice, cleaning up the timer metadata when deleting a timer function ensures it won’t resurrect unexpectedly.
If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.
hth
Marcin