From dbe8f26c6d8dea47bb53af30c1355b2ce88973c2 Mon Sep 17 00:00:00 2001
From: Jordan Matthiesen <1333029+jmatthiesen@users.noreply.github.com>
Date: Tue, 22 Oct 2024 01:18:03 -0700
Subject: [PATCH] Updated to Aspire 9 (#3)
* Updated to Aspire 9.
* Fixing a bad version number
* Working to fix version numbers
* Fixing version number
---
.github/workflows/template-validation.yml | 2 +-
src/AIChatApp.AppHost/AIChatApp.AppHost.csproj | 9 +++------
.../AIChatApp.ServiceDefaults.csproj | 10 +++-------
src/AIChatApp.ServiceDefaults/Extensions.cs | 18 +++++++++++++-----
src/AIChatApp.Web/AIChatApp.Web.csproj | 6 +-----
.../Properties/launchSettings.json | 9 ++++++---
6 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/.github/workflows/template-validation.yml b/.github/workflows/template-validation.yml
index ccc305f..34397df 100644
--- a/.github/workflows/template-validation.yml
+++ b/.github/workflows/template-validation.yml
@@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- - uses: microsoft/template-validation-action@v0.1
+ - uses: microsoft/template-validation-action@v0.2.2
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
diff --git a/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj b/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj
index 2aea3c1..e78c707 100644
--- a/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj
+++ b/src/AIChatApp.AppHost/AIChatApp.AppHost.csproj
@@ -1,5 +1,5 @@
-
+
Exe
net8.0
@@ -8,14 +8,11 @@
true
bfbf6497-561a-489f-b904-9e0f105be895
-
-
+
-
-
-
+
\ No newline at end of file
diff --git a/src/AIChatApp.ServiceDefaults/AIChatApp.ServiceDefaults.csproj b/src/AIChatApp.ServiceDefaults/AIChatApp.ServiceDefaults.csproj
index ae38594..fffb423 100644
--- a/src/AIChatApp.ServiceDefaults/AIChatApp.ServiceDefaults.csproj
+++ b/src/AIChatApp.ServiceDefaults/AIChatApp.ServiceDefaults.csproj
@@ -1,22 +1,18 @@
-
net8.0
enable
enable
true
-
-
-
-
+
+
-
-
+
\ No newline at end of file
diff --git a/src/AIChatApp.ServiceDefaults/Extensions.cs b/src/AIChatApp.ServiceDefaults/Extensions.cs
index ce94dc2..13151bf 100644
--- a/src/AIChatApp.ServiceDefaults/Extensions.cs
+++ b/src/AIChatApp.ServiceDefaults/Extensions.cs
@@ -3,6 +3,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
@@ -14,7 +15,7 @@ namespace Microsoft.Extensions.Hosting;
// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
public static class Extensions
{
- public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
+ public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.ConfigureOpenTelemetry();
@@ -31,10 +32,16 @@ public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBu
http.AddServiceDiscovery();
});
+ // Uncomment the following to restrict the allowed schemes for service discovery.
+ // builder.Services.Configure(options =>
+ // {
+ // options.AllowedSchemes = ["https"];
+ // });
+
return builder;
}
- public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicationBuilder builder)
+ public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Logging.AddOpenTelemetry(logging =>
{
@@ -51,7 +58,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
})
.WithTracing(tracing =>
{
- tracing.AddAspNetCoreInstrumentation()
+ tracing.AddSource(builder.Environment.ApplicationName)
+ .AddAspNetCoreInstrumentation()
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
//.AddGrpcClientInstrumentation()
.AddHttpClientInstrumentation();
@@ -62,7 +70,7 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati
return builder;
}
- private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostApplicationBuilder builder)
+ private static TBuilder AddOpenTelemetryExporters(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
@@ -81,7 +89,7 @@ private static IHostApplicationBuilder AddOpenTelemetryExporters(this IHostAppli
return builder;
}
- public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
+ public static TBuilder AddDefaultHealthChecks(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
diff --git a/src/AIChatApp.Web/AIChatApp.Web.csproj b/src/AIChatApp.Web/AIChatApp.Web.csproj
index a2928ec..c5ff91f 100644
--- a/src/AIChatApp.Web/AIChatApp.Web.csproj
+++ b/src/AIChatApp.Web/AIChatApp.Web.csproj
@@ -1,5 +1,4 @@
-
net8.0
enable
@@ -7,15 +6,12 @@
AIChatApp
b0ee5b46-677b-4906-bcc3-e74dafe7a50f
-
-
-
-
+
\ No newline at end of file
diff --git a/src/AIChatApp.Web/Properties/launchSettings.json b/src/AIChatApp.Web/Properties/launchSettings.json
index dfab0d4..33ab031 100644
--- a/src/AIChatApp.Web/Properties/launchSettings.json
+++ b/src/AIChatApp.Web/Properties/launchSettings.json
@@ -15,7 +15,8 @@
"launchBrowser": true,
"applicationUrl": "http://localhost:5153",
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
+ "ASPNETCORE_ENVIRONMENT": "Development",
+ "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:22079"
}
},
"https": {
@@ -24,7 +25,9 @@
"launchBrowser": true,
"applicationUrl": "https://localhost:7243;http://localhost:5153",
"environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
+ "ASPNETCORE_ENVIRONMENT": "Development",
+ "DOTNET_ENVIRONMENT": "Development",
+ "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22128"
}
},
"IIS Express": {
@@ -35,4 +38,4 @@
}
}
}
-}
+}
\ No newline at end of file