A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Azure/azure-functions-host/issues/4520 below:

GitHub ยท Where software is built

I have same tried this with and without a typed client as suggested in #4344 but with the same result.

The HttpClient is always disposed of between runs resulting in
Cannot access a disposed object. Object name: 'System.Net.Http.HttpClient'.

[assembly: FunctionsStartup(typeof(Orders.Collector.Startup))]
namespace Orders.Collector
{
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddHttpClient<OrdersCollector>();
        }
    }
}
{
    public class OrdersCollector
    {

        private readonly HttpClient _client;

        public OrdersCollector(HttpClient client)
        {
            _client= client;
        }


        [FunctionName("OrdersCollector")]
        public async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
        //Do some processing
         return (ActionResult)new OkObjectResult("Data collection completed");
        }
}

it is the same result with the emulator & Function App, runs fine first time but not subsequently.

Predictably restarting the Function App resets everything and it will run one time again.

Azure Functions Core Tools (2.7.1158 Commit hash: f2d2a28)
Function Runtime Version: 2.0.12438.0


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4