How to get parameter binding in Azure Function - isolated process?

Verburgh, I (Ivo) 55 Reputation points
2023-03-06T15:42:40.8166667+00:00

We have a lot of Azure Functions that make use of a HttpTrigger.

The possible parameters for these functions are passed via a custom object and the properties (from QueryString of Body) are automatically mapped to the custom object.

We understood that if we want to stay up to date with our Azure Functions, that it is smart to update them to .NET 8: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/net-on-azure-functions-roadmap-update/ba-p/3619066

.NET 8 only supports isolated process Azure Functions and when we tried this out, we noticed that Parameter Binding wasn't working anymore like described above.
I can't imagine that it is the intention that we write this logic ourselves, so when can expect this functionality to arrive in Azure Functions - isolated process?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,907 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,801 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,311 Reputation points
    2023-03-10T20:20:16.0333333+00:00

    Verburgh, I (Ivo) In Isolated process model, currently it is not automatically binding properties to model. Unfortunately, you have to manually call extension method ReadFromJsonAsync for binding the request body to a model and to retrieve query string, use System.Web.HttpUtility.ParseQueryString(req.Url.Query). We are making changes (PR) to add Query property to HttpRequestData and this would help in future.

    Here is the sample code snippet:

    [Function("HttpIsolated")]
            public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req)
            {
                _logger.LogInformation("C# HTTP trigger function processed a request.");
    
                try
                {
                    var request = new StreamReader(req.Body).ReadToEnd();
                    var parameterObjectBody = req.ReadFromJsonAsync<ParameterObjectBody>();
                    var query = System.Web.HttpUtility.ParseQueryString(req.Url.Query);
                }
                catch (Exception ex)
                {
                }
    
                var response = req.CreateResponse(HttpStatusCode.OK);
                response.Headers.Add("Content-Type", "text/plain; charset=utf-8");
    
                response.WriteString("Welcome to Azure Functions!");
    
                return response;
            }
    

    I understand your feedback and totally agree with you that it would be great to have parameter binding like in-process. I have shared your feedback with our product team internally, and based on the discussion, our product team is currently focusing on HTTP model enhancements to address current limitations with HTTP model. While that should bring improvements, you can track this feature via HttpTrigger with complex type does not work and feel free to comment on the issue.

    I hope this helps with question and let me know for any other questions.


    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    4 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.