

Add psycopg2-binary to your requirements.txt. If not, then the possible issue is using psycopg2.

('Python timer trigger function ran at %s', utc_timestamp) I am not sure if your requirement is to connect to Azure PostgreSQL using Managed Identity. import loggingĭef main(mytimer: func.TimerRequest) -> None: Then I switched to psycopg2-binary and the exception went away. Moreover, initially I was using psycopg2 and I was receiving the exception in here. Not in the function insights nor in the storage account that is defined for the function. could not connect to server: Connection refused Is the server running on host '127.0.0. if connection:"įurthermore, I can not see any logs even though I'm writing them in the function body. "Exception while executing function: Functions.FunctionTrigger Result: FailureĮxception: UnboundLocalError: local variable 'connection' referenced before assignment. Here's the Exception that I'm getting when running the function: I did not find anything in the function properties/configuration on os.environ, os.environ so I'm assuming that these are being assigned by microsoft when the function gets executed. According to this article you need to use the api version if function is on Linux Consumption plan. Function is on Linux Consumption plan.

