Azure function fails with Communication link failure

Daniel 26 Reputation points
2022-03-28T03:51:20.967+00:00

I have encountered a similar issue with a few of my Azure Functions, where the function would be deployed and would run as required. Until, at some (random) point, an error message of the following form would appear:

Exception while executing function: Functions.HttpTimer Result: Failure
Exception: OperationalError: ('08S01', '[08S01] [Microsoft][ODBC Driver 17 for SQL Server]Communication link failure (0) (SQLExecDirectW)')
Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 402, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 611, in _run_sync_func
return ExtensionManager.get_sync_invocation_wrapper(context,
File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/extension.py", line 215, in _raw_invocation_wrapper
result = function(**args)

........

After which the function would fail with the same error message each subsequent time that it was scheduled to run.
Then, when the function would be redeployed it would, again, run as required.

I wanted to know what could be done to stop this from happening in the future.

Any help would be greatly appreciated.

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,684 questions
{count} vote

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,286 Reputation points
    2022-03-28T08:33:42.6+00:00

    @Daniel ,

    Thanks for reaching out to Q&A.

    There are many reasons that could cause "Communication link failure (0)" issue. This is a very generic error message. In order to troubleshoot this issue, this needs to be isolated first. Either there is a problem at the Functions platform side or a problem at the SQLserver/ODBC driver.

    Functions:

    Run the "Function app down or reporting errors" detector available in the Diagnose and solve problems blade in Functions portal during the time the issue was seen. This would tell you if there is any problem at the Functions side.

    SQL:

    Check the logs (application/server/event) at the SQL server side to see if there were any updates/errors/down time that coincides with the errors.

    If the issue is seen intermittently and occurs very rarely, this could be a transient issue as well. Having a retry mechanism would help. I have seen issues like this in the past where there were some issues at the sql side and the function app was failing with similar message, once the sql issue was resolved and the function app was restarted, the error was not seen anymore.

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