Azure function app throws "database communication link failure" error and stops working
The HTTP triggered function app is built using Python 3.x and uses pyodbc with ODBC Driver 17 for SQL Server to communicate with the SQL server DB which has been deployed in the same resource group and the same region. The function app throws ('08S01', '[08S01] [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure (0) (SQLExecDirectW)') error (used logs to validate) from time to time and returns an error as the response.
This issue gets immediately resolved once we re-deploy the function app and keeps working for a period of time and becomes apparent again (re-deployed yesterday evening due to the issue and worked fine until re-checked in the morning and the issue was there again). This function app was working as expected until a couple of days before when we released a newer version with some improvements.
We have the exact same function app (the latest version) and setup (including the DB) deployed in 2 other Azure directories (the Dev and Test instances) and they are working without a hitch. The only difference is the service tier (the production version uses a premium plan while the dev and test use consumption plans).
Tried disabling the "always on - keeping at least one function app instance running" feature on the premium plan to verify whether it's due to a DB session issue but that didn't work as well. Also added the IP of the function app in the DB whitelist just in case (The azure resources can access the DB feature is also on so, adding the IP of the function app is not mandatory I guess) and that didn't work too.
Any support or expertise on the subject matter would be appreciated