MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.22k stars 21.37k forks source link

HttpRequest vs HttpRequestMessage #34562

Closed SlowFourierTransform closed 5 years ago

SlowFourierTransform commented 5 years ago

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:


Document Details

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

DixitArora-MSFT commented 5 years ago

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

mike-urnun-msft commented 5 years ago

@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.

SlowFourierTransform commented 5 years ago

@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)

mike-urnun-msft commented 5 years ago

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.

nhwilly commented 5 years ago

FWIW: https://github.com/MicrosoftDocs/azure-docs/issues/37298