Hello @Matthew Castrigno
To resolve this issue, you can try adding a try-catch block around the code in the function and return an appropriate response to the browser in case of an exception.
For example:
public static class ValidateFunction {
[FunctionName("Validate")]
public static async Task Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
try {
log.LogInformation("Validate HTTP trigger function processed a request.");
var responsebody = await HttpService.LeanIXAPI.Validate();
var writeResponse = FtpService.WriteFTP.WriteToArcherFTP(responsebody, "test", "./ValidationResults.txt");
log.LogInformation($"Validate response was: {writeResponse}");
return new OkResult();
}
catch (Exception ex)
{
log.LogError(ex, "An error occurred in the Validate function.");
return new StatusCodeResult(StatusCodes.Status500InternalServerError);
}
}
}
In this example, the function returns an HTTP 200 OK response if the function completes successfully, and an HTTP 500 Internal Server Error response if an exception is thrown. You can modify the response as per your requirement.
I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.