diff --git a/OddsCollector.Functions/Functions/PredictionsHttpFunction.cs b/OddsCollector.Functions/Functions/PredictionsHttpFunction.cs deleted file mode 100644 index eecc64b..0000000 --- a/OddsCollector.Functions/Functions/PredictionsHttpFunction.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Net; -using System.Text.Json; -using Microsoft.Azure.Functions.Worker; -using Microsoft.Azure.Functions.Worker.Http; -using Microsoft.Extensions.Logging; -using OddsCollector.Functions.CosmosDb; - -namespace OddsCollector.Functions.Functions; - -public class PredictionsHttpFunction(ILogger logger, ICosmosDbClient? client) -{ - private readonly ICosmosDbClient _client = client ?? throw new ArgumentNullException(nameof(client)); - private readonly ILogger _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - private static readonly JsonSerializerOptions _serializerOptions = new() { WriteIndented = true }; - - [Function(nameof(PredictionsHttpFunction))] - public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData request, - CancellationToken cancellationToken) - { - try - { - var predictions = await _client.GetEventPredictionsAsync(cancellationToken).ConfigureAwait(false); - - var serialized = JsonSerializer.Serialize(predictions, _serializerOptions); - - var response = request.CreateResponse(HttpStatusCode.OK); - response.Headers.Add("Content-Type", "text/plain; charset=utf-8"); - response.WriteString(serialized); - - return response; - } - catch (Exception exception) - { - var message = "Failed to return predictions"; - - _logger.LogError(exception, message); - - var response = request.CreateResponse(HttpStatusCode.InternalServerError); - response.Headers.Add("Content-Type", "text/plain; charset=utf-8"); - response.WriteString(message); - - return response; - } - } -} diff --git a/OddsCollector.Functions/Program.cs b/OddsCollector.Functions/Program.cs index 3bd9b13..24eee99 100644 --- a/OddsCollector.Functions/Program.cs +++ b/OddsCollector.Functions/Program.cs @@ -1,7 +1,6 @@ using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using OddsCollector.Functions.CosmosDb; using OddsCollector.Functions.OddsApi.Configuration; using OddsCollector.Functions.Strategies; @@ -9,14 +8,6 @@ .ConfigureFunctionsWorkerDefaults() .ConfigureServices(services => { - services.AddSingleton( - ContainerFactory.CreateContainer( - // workaround for https://github.com/MicrosoftDocs/azure-docs/issues/32962 - Environment.GetEnvironmentVariable("CosmosDb:Connection"), - Environment.GetEnvironmentVariable("CosmosDb:Database"), - Environment.GetEnvironmentVariable("CosmosDb:EventPredictionsContainer") - )); - services.AddSingleton(); services.AddSingleton(); services.AddOddsApiClientWithDependencies(); services.AddApplicationInsightsTelemetryWorkerService();