Azure-docs: HttpRequest vs HttpRequestMessage

Created on 4 Jul 2019  Â·  5Comments  Â·  Source: MicrosoftDocs/azure-docs

The examples on this page use the class HttpRequest for the input binding, but it is hard to use (you need a StreamReader just to read the request body). I've used HttpRequestMessage from System.Net.Http instead in my functions which is much easier to use:

  • var json = await req.Content.ReadAsStringAsync();
  • var meeting = await req.Content.ReadAsAsync<OfficeMeeting>();
    It seems much easier to use, so I'm wonder why HttpRequest is the suggested usage in the documentation.

Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 azure-functionsvc cxp product-question triaged

Most helpful comment

@mike-urnun-msft Thanks for the feedback. My suggestion is to include HttpRequestMessage in the "Trigger - usage" section to help others learn that they can use it as well. The Azure Blob Storage triggers has a useful list of possible objects you can use. It would be helpful to see something like that in the HTTP triggers docs (especially since HTTP is probably the most popular trigger)

All 5 comments

Hi @JamesFenton Thank you for your feedback! We will review and provide an update as appropriate.

@JamesFenton Thanks again for sharing your feedback! You can certainly use one of the other depending on whichever one suits better for your unique requirements and ensuing implementation. While HttpRequest API provides more properties & granular info about the request directly, HttpRequestMessage API can also be more straight-forward to use as get-go too.

@mike-urnun-msft Thanks for the feedback. My suggestion is to include HttpRequestMessage in the "Trigger - usage" section to help others learn that they can use it as well. The Azure Blob Storage triggers has a useful list of possible objects you can use. It would be helpful to see something like that in the HTTP triggers docs (especially since HTTP is probably the most popular trigger)

Hi @JamesFenton - Thank you for your suggestion. While HttpRequestMessage was being used widely with Functions v1, if you're on v2, our recommendation is to use HttpRequest instead. Moreover, in an effort to staying consistent with the way boilerplate HTTP functions are created with our tools (VS, VS Code, CLI, etc..) currently, we'll hold off from making this update on the said section for now.

We will now proceed to close this thread. If there are further questions regarding this use case, please open an issue on Functions host repo to discuss this matter directly with the Functions team.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bityob picture bityob  Â·  3Comments

ianpowell2017 picture ianpowell2017  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments

mrdfuse picture mrdfuse  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments