I need to build an Azure Function that:
HTTP POST
requestHTTP HEAD
requests based on the data.I've found some guidance here and here
But, it's not entirely clear what to do, and how it works?
As in the second link, i've currently just declared a private static HttpClient httpClient = new HttpClient();
instance, and re-used that in my 7x HTTP HEAD calls.
My questions:
HttpClient
in a stateless Azure function?List<Task>()
for the http calls, then doing Task.WhenAll(tasks)
on them to run them in parrallel. Would that be the quickest way to do these calls? Any other suggestions?This Function endpoint will be called a lot (multiple times a second), so need to be as efficient as possible to keep costs down.
Thanks!
Yes - this is still the current guidance for Azure Functions 1.x (and applies to 2.x as well) to best avoid socket exhaustion. The static variable will ensures that it will be shared against all instances of the class. Another good article that covers this topic is https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong