-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#17 - update azure function to .net 8
- Loading branch information
Showing
7 changed files
with
35 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
content/BlazorSwaTemplate/BlazorSwaTemplate.Api.Isolated/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.ConfigureFunctionsWebApplication() | ||
.ConfigureServices(services => | ||
{ | ||
services.AddApplicationInsightsTelemetryWorkerService(); | ||
services.ConfigureFunctionsApplicationInsights(); | ||
}) | ||
.Build(); | ||
|
||
host.Run(); |
19 changes: 8 additions & 11 deletions
19
content/BlazorSwaTemplate/BlazorSwaTemplate.Api.Isolated/WeatherForecastFunction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,37 @@ | ||
using BlazorSwaTemplate.Shared; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Azure.Functions.Worker.Http; | ||
using Microsoft.Extensions.Logging; | ||
using System.Net; | ||
using BlazorSwaTemplate.Shared; | ||
|
||
namespace BlazorSwaTemplate.Api; | ||
|
||
public class WeatherForecastFunction | ||
{ | ||
private readonly ILogger _logger; | ||
private readonly ILogger<WeatherForecastFunction> _logger; | ||
|
||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
public WeatherForecastFunction(ILoggerFactory loggerFactory) | ||
public WeatherForecastFunction(ILogger<WeatherForecastFunction> logger) | ||
{ | ||
_logger = loggerFactory.CreateLogger<WeatherForecastFunction>(); | ||
_logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
} | ||
|
||
[Function("WeatherForecast")] | ||
public async Task<HttpResponseData> Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequestData req) | ||
public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get")] HttpRequest req) | ||
{ | ||
_logger.LogInformation("C# HTTP trigger function processed a request."); | ||
|
||
var response = req.CreateResponse(HttpStatusCode.OK); | ||
|
||
var forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = DateTime.Now.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray(); | ||
|
||
await response.WriteAsJsonAsync(forecasts); | ||
return response; | ||
return new OkObjectResult(forecasts); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
"samplingSettings": { | ||
"isEnabled": true, | ||
"excludedTypes": "Request" | ||
} | ||
}, | ||
"enableLiveMetricsFilters": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters