I have a Logic App that calls an AZURE FUNCTION App and appears to be working correctly ie no errors in the LOGIC APP. However, after reviewing data in the DB that the FUNCTION App writes to I have found it began to stop writing about a week ago. Someone not calling out the server team removed the user "By Accident". The strange part is that the LOGIC APP says successful. When I tested the Function APP in my VS IDE, I got an error on the insert statement of the records. I have a try-catch block and the error is caught in the Catch and is written to
log.LogInformation(error on DB insert " + DateTime.Now.ToString("h:mm:ss tt")); Console.Write(ex.Message) message below. How can I get the Function app error out to my Logic app as a fail?
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)
I do agree with @Skin that you need to rethrow to get that exception error message to logic app which is waiting for Azure Functions response.
In c# code:
Try
{
......
}
Catch(Exception e)
{
throw; // rethrwoing
}
In python:
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
try:
result = 1 / 0
return func.HttpResponse(f"Hello Rithwik Bojja: {result}")
except ZeroDivisionError as rith:
logging.error("Hello Rithwik Bojja, ZeroDivisionError raised: %s", rith)
raise