When testing the CreateLessonPlan endpoint in my local Azure Function App, the request consistently fails while being proxied from the host to the worker.
All other APIs are working correctly — this issue only occurs with this specific endpoint.
I’m using Azure Functions on http://localhost:7071, and the function Functions.CreateLessonPlan fails with a stream consumption error inside the YARP reverse proxy. The host retries several times and finally throws Stream was already consumed.
This seems related to how the request body stream is handled inside the proxy layer or by the function runtime.
Endpoint tested:
POST http://localhost:7071/api/lessonplans
Request body:
{ "SubjectId": 1, "TeacherId": "628d0f85-6915-4df6-b769-c636e433abab", "School": "Trường THPT Kim Sơn B", "Class": "12A1", "LessonTitle": "Bài 1. Định nghĩa – Quy tắc tính đạo hàm", "Time": "1 tiết" } Observed behavior:
Function host calls
Functions.CreateLessonPlan.Request authentication succeeds but userId and role are null.
Proxy retries 10 times before failing.
The error shows that the request stream was already consumed.
Logs excerpt:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.InvalidOperationException: Stream was already consumed. at Yarp.ReverseProxy.Forwarder.StreamCopyHttpContent.SerializeToStreamAsync(...) Expected behavior:
The API should execute normally and return a generated lesson plan response, just like other endpoints in the project.
Additional context:
The warning messages about missing decimal precision (
HasColumnType,HasPrecision, etc.) appear unrelated to the crash.The proxy error occurs immediately after authentication and before EF Core writes any data.
This issue may be caused by reusing the request body stream or a custom middleware that reads the stream twice.