Open Laumania opened 3 months ago
Any news or input on this - anyone?
facing this same issue with a POST function app.
Model binding is not happening for my POCO class when using the [FromBody] attribute in the function parameters
facing this same issue with a POST function app.
Model binding is not happening for my POCO class when using the [FromBody] attribute in the function parameters
POST works, but you need the right FromBody on - this one: [Microsoft.Azure.Functions.Worker.Http.FromBody]
However, I can't get it to work for GET and it's a showstopper for us right now as it seems like a step backward to have to manually parse parameters into a POCO.
For anyone that's currently looking for this, I put together a NuGet package that adds support for binding query parameters:
// Bind directly to primitive types:
// BindPrimatives?id=abc123&skip=0&take=10
[Function("BindPrimitives")]
public HttpResponseData BindPrimitives(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[BindQuery] string id,
[BindQuery] int skip,
[BindQuery] int take)
{
// ..
}
// Or POCOs:
// BindPOCOs?id=abc123&skip=0&take=10
[Function("BindPOCOs")]
public HttpResponseData BindPOCOs(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
[BindQuery] DummyPoCo parameters)
{
// ..
}
Or feel free to grab the code directly here:
https://github.com/erinnmclaughlin/AzureFunctionsWorkerHttpExtensions
I'm hoping to open up a PR for this as well, but wanted to get something out there in the meantime!
What version of .NET does your existing project use?
.NET 6
What version of .NET are you attempting to target?
.NET 8
Description
We are upgrading our .NET 6 in-process function apps to .NET 8 isolated.
In general, upgrade have been fairly easy and doable. Therefore I was also very surprised when I discovered that our custom PoCo request parameters was always null in our GET HTTPTriggers.
POST works, by adding [Microsoft.Azure.Functions.Worker.Http.FromBody], but GET parameters is not working.
After many hours of research, I was surprised to figure out this was not support!
This 1 year old post, describes the exact same problem - what use to work out of the box in .NET 6 in-process is not working in .NET 8 and isolated. https://learn.microsoft.com/en-us/answers/questions/1186948/how-to-get-parameter-binding-in-azure-function-iso
As Microsoft are forcing us to .NET 8 and isolated before end of 2026, this have to be implemented, as I assume a lot of people need this.
I'm sorry, but its simply not good enough to manually have to do this via the HttpRequestData.
So is this something that is on the roadmap - I really hope so :)
Project configuration and dependencies
Link to a repository that reproduces the issue
No response