How do I return JSON from an Azure Function

前端 未结 7 1400
逝去的感伤
逝去的感伤 2021-02-06 20:43

I am playing with Azure Functions. However, I feel like I\'m stumped on something pretty simple. I\'m trying to figure out how to return some basic JSON. I\'m not sure how to cr

7条回答
  •  情歌与酒
    2021-02-06 21:33

    You can take req from

    public static async Task Run(HttpRequestMessage req, TraceWriter log)
    

    and create the response using

    return req.CreateResponse(HttpStatusCode.OK, json, "application/json");
    

    or any of the other overloads in assembly System.Web.Http.

    More info on docs.microsoft.com

提交回复
热议问题