I would like to get Azure Function result in FunctionInvocationFilterAttribute to be able to check whether the returned value was successful (200 OK or an error status in case of IActionResult).
public class AuditAttribute: FunctionInvocationFilterAttribute
{
public override Task OnExecutedAsync(FunctionExecutedContext executedContext, CancellationToken cancellationToken)
{
if (!(executedContext.Arguments.Values.FirstOrDefault(argument => argument is HttpRequest) is HttpRequest httpRequest))
{
throw new ArgumentException("Audit attribute requires azure functions with HttpRequest parameter");
}
if (!(httpRequest.HttpContext.Items["audit"] is Audit audit))
{
throw new ArgumentException("Audit object is missing in HttpContext");
}
audit.FunctionResult = executedContext.FunctionResult.Succeeded; // Here I'd I like to get the result not just `true`
}
}
I would like to get Azure Function result in
FunctionInvocationFilterAttribute
to be able to check whether the returned value was successful (200 OK or an error status in case ofIActionResult
).The result is returned from InvokeAsync in FunctionExecutor but is not passed further to the FunctionExecutedContext. Instead hardcoded
true
value is passed.