Description
When using the .NET Core integration the HttpRequestData.Body property is unabled to be read more than once.
Since the stream has "CanSeek" set to false, we cannot reset its position before the HTTP Trigger picks up the request.
I'm unsure if this is intended or not, but it means that it is impossible to read the request body in a middleware, and also process the request in the function itself. This works as expected when not using the .NET Core integration.
There seems to be a different implementation of HttpRequestData, AspNetCoreHttpRequestData when using the .NET Core integration, and GrpcHttpRequestData when using the normal worker.
Repository to reproduce the issue: https://github.com/rustichowie/AzureFunction.StreamReadBug
Repro steps
- Create a new Azure Function using the default template
- Add a simple middleware that reads from the request body and reset the stream position back to zero.
- Add a HTTP Trigger that also tries to read from the same request body
Expected behavior
Expected behavior is for this to work without throwing an exception.
Actual behavior
Setting the position of the stream back to zero causes an NotSupportedException to be thrown.