From f9231d9aeeab99f8c6d8f9dcc992b34cf2f1b5e4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 15:53:34 +0000 Subject: [PATCH 1/2] Initial plan From 4ebabaa6d2d3c3438a39ade679f13ca59c20fa51 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 19 Feb 2026 15:57:57 +0000 Subject: [PATCH 2/2] Use IHttpClientFactory to avoid HttpClient socket exhaustion in OpenAiRedactionFunction Co-authored-by: mark-quickel <112185610+mark-quickel@users.noreply.github.com> --- src/custom-skills/Functions/OpenAiRedactionFunction.cs | 7 ++++--- src/custom-skills/Program.cs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/custom-skills/Functions/OpenAiRedactionFunction.cs b/src/custom-skills/Functions/OpenAiRedactionFunction.cs index 3e33c3c..122448c 100644 --- a/src/custom-skills/Functions/OpenAiRedactionFunction.cs +++ b/src/custom-skills/Functions/OpenAiRedactionFunction.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; -using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.ML.Tokenizers; using Microsoft.SemanticKernel; @@ -17,10 +16,12 @@ namespace PhiDeidPortal.CustomFunctions.Functions public class OpenAIRedactionFunction { private readonly ILogger _logger; + private readonly IHttpClientFactory _httpClientFactory; - public OpenAIRedactionFunction(ILogger logger) + public OpenAIRedactionFunction(ILogger logger, IHttpClientFactory httpClientFactory) { _logger = logger; + _httpClientFactory = httpClientFactory; } [Function("OpenAiRedactionFunction")] @@ -48,7 +49,7 @@ public async Task Run([HttpTrigger(AuthorizationLevel.Function, " _logger.LogInformation($"Deployment Name: {Environment.GetEnvironmentVariable(EnvironmentVariables.OpenAiDeploymentName)}"); _logger.LogInformation($"End Point: {Environment.GetEnvironmentVariable(EnvironmentVariables.OpenAiEndpoint)}"); - var client = new HttpClient() { Timeout = TimeSpan.FromMinutes(5) }; + var client = _httpClientFactory.CreateClient("OpenAI"); kernel = Kernel.CreateBuilder() .AddAzureOpenAIChatCompletion( diff --git a/src/custom-skills/Program.cs b/src/custom-skills/Program.cs index 689224b..862eadf 100644 --- a/src/custom-skills/Program.cs +++ b/src/custom-skills/Program.cs @@ -16,6 +16,7 @@ .ConfigureServices(services => { services.AddApplicationInsightsTelemetryWorkerService(); services.ConfigureFunctionsApplicationInsights(); + services.AddHttpClient("OpenAI", client => { client.Timeout = TimeSpan.FromMinutes(5); }); }) .Build();