I have a filter on an Azure Function that performs some tasks right after the the main function action has completed.
public async Task<IActionResult> DoStuff(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "notImportant")]
HttpRequest req,
ClaimsPrincipal principal)
{
string bodyContent = await new StreamReader(req.Body).ReadToEndAsync(); //Always has content
}
My Filter looks like this:
public class TraceAuditFilter : IFunctionInvocationFilter
{
public TraceAuditFilter()
{
}
public async Task OnExecutedAsync(FunctionExecutedContext executedContext, CancellationToken cancellationToken)
{
var request = (HttpRequest)executedContext.Arguments["req"];
string body = new StreamReader(req.Body).ReadToEnd(); //Always Empty
}
}
My filter sucessfully fires, but the 'body' in the filter method is always Empty. Any ideas what is resetting it?