Azure函数C#Http Trigger不返回响应

时间:2016-10-20 05:57:50

标签: c# azure httpresponse azure-functions

如果在C#中有一个简单的HTTP触发函数,它不会返回结果:

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}
    );
}

我使用POSTMAN检查了HTTP标头是否设置正确,但只是在没有响应主体的情况下获得200 OK。

1 个答案:

答案 0 :(得分:2)

事后看来,解决方案显而易见: 我必须定义HTTP响应输出,而不更改Azure Functions运行时上面的代码,自动连接req.CreateResponse

defining a HTTP Response output binding