简体   繁体   中英

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.

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 .

定义HTTP响应输出绑定

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM