Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions C# Http Trigger does not return response

If have a simple HTTP triggered function in C# which just doesn't return the result:

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log)
{
    string jobId = req.Headers.GetValues("scheduler-jobid").FirstOrDefault();
    string executionTime = req.Headers.GetValues("scheduler-expected-execution-time").FirstOrDefault();

    return req.CreateResponse(HttpStatusCode.OK,new {
        JobId = jobId,
        ExecutionTime = executionTime}
    );
}

I checked with POSTMAN that HTTP headers are set correctly but just get a 200 OK without a response body.

like image 674
Kai Walter Avatar asked Mar 30 '26 18:03

Kai Walter


1 Answers

In hindsight the solution is obvious: I had to define a HTTP Response output and without changing the code above the Azure Functions runtime automatically wires in the req.CreateResponse.

defining a HTTP Response output binding

like image 129
Kai Walter Avatar answered Apr 01 '26 10:04

Kai Walter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!