Skip to content

Commit d79dd5a

Browse files
authored
Merge pull request #9 from BezaluLLC/dotnet9
Dotnet9
2 parents dac6895 + a016d50 commit d79dd5a

File tree

14 files changed

+438
-566
lines changed

14 files changed

+438
-566
lines changed

src/Signal9.Agent.Functions/Signal9.Agent.Functions.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
66
<OutputType>Exe</OutputType>
77
<ImplicitUsings>enable</ImplicitUsings>
88
<Nullable>enable</Nullable>
99
<AssemblyName>Signal9.Agent.Functions</AssemblyName>
1010
<RootNamespace>Signal9.Agent.Functions</RootNamespace>
11+
<LangVersion>default</LangVersion>
1112
</PropertyGroup>
1213

1314
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
15-
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
15+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
16+
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.5" />
1617
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
1718
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.SignalRService" Version="1.7.0" />
1819
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.1" />
1920
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
2021
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
21-
<PackageReference Include="Azure.Identity" Version="1.11.4" />
22+
<PackageReference Include="Azure.Identity" Version="1.13.1" />
2223
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.0" />
2324
</ItemGroup>
2425

src/Signal9.Agent.Functions/Signal9.RMM.Functions.csproj

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/Signal9.Agent/Program.cs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,53 @@
44
using Microsoft.Extensions.Configuration;
55
using Signal9.Agent.Services;
66
using Signal9.Shared.Configuration;
7+
using System.Text.Json;
78

89
var builder = Host.CreateApplicationBuilder(args);
910

10-
// Add configuration
11+
// Add configuration with .NET 9 enhancements
1112
builder.Configuration
1213
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
1314
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true)
14-
.AddEnvironmentVariables();
15+
.AddEnvironmentVariables()
16+
.AddUserSecrets<Program>(optional: true);
1517

16-
// Add logging
18+
// Add enhanced logging with .NET 9 structured logging
1719
builder.Services.AddLogging(logging =>
1820
{
1921
logging.ClearProviders();
2022
logging.AddConsole();
21-
if (OperatingSystem.IsWindows())
23+
24+
// Add structured logging with .NET 9 improvements
25+
logging.AddSimpleConsole(options =>
2226
{
23-
logging.AddEventLog();
24-
}
27+
options.IncludeScopes = true;
28+
options.SingleLine = true;
29+
options.TimestampFormat = "[yyyy-MM-dd HH:mm:ss] ";
30+
});
2531
});
2632

27-
// Add configuration options
33+
// Add configuration options with validation
2834
builder.Services.Configure<AgentConfiguration>(
2935
builder.Configuration.GetSection("AgentConfiguration"));
3036

31-
// Add services
37+
// Add services with .NET 9 performance improvements
3238
builder.Services.AddSingleton<ITelemetryCollector, TelemetryCollector>();
3339
builder.Services.AddSingleton<ISystemInfoProvider, SystemInfoProvider>();
3440
builder.Services.AddHostedService<AgentService>();
3541

42+
// Add HttpClient with .NET 9 optimizations
43+
builder.Services.AddHttpClient("Signal9Api", client =>
44+
{
45+
client.BaseAddress = new Uri(builder.Configuration["Signal9Api:BaseUrl"] ?? "https://api.signal9.com");
46+
client.Timeout = TimeSpan.FromSeconds(30);
47+
});
48+
3649
var host = builder.Build();
3750

3851
// Create logger for startup
3952
var logger = host.Services.GetRequiredService<ILogger<Program>>();
40-
logger.LogInformation("Signal9 Agent starting up");
53+
logger.LogInformation("Signal9 Agent starting up with .NET 9 optimizations");
4154

4255
try
4356
{
@@ -51,4 +64,5 @@
5164
finally
5265
{
5366
logger.LogInformation("Signal9 Agent shutting down");
67+
await host.StopAsync();
5468
}

0 commit comments

Comments
 (0)