diff --git a/template/src/Placeholder.AppHost/Program.cs b/template/src/Placeholder.AppHost/Program.cs index 5d41827..4d07d72 100644 --- a/template/src/Placeholder.AppHost/Program.cs +++ b/template/src/Placeholder.AppHost/Program.cs @@ -4,15 +4,20 @@ var weatherDb = builder.ConfigurePostgresDatabase("weather", builder.AddParameter("postgresUsername"), builder.AddParameter("postgresPassword", secret: true)); +var appInsights = builder.AddConnectionString("AppInsights", "APPLICATIONINSIGHTS_CONNECTION_STRING"); + var apiService = builder.AddProject("apiservice") .WithExternalHttpEndpoints() - .WithReference(weatherDb); + .WithReference(weatherDb) + .WithReference(appInsights); builder.AddProject("migration") - .WithReference(weatherDb); + .WithReference(weatherDb) + .WithReference(appInsights); builder.AddProject("webfrontend") .WithExternalHttpEndpoints() - .WithReference(apiService); + .WithReference(apiService) + .WithReference(appInsights); builder.Build().Run(); diff --git a/template/src/Placeholder.ServiceDefaults/Extensions.cs b/template/src/Placeholder.ServiceDefaults/Extensions.cs index a9f6a5c..c993154 100644 --- a/template/src/Placeholder.ServiceDefaults/Extensions.cs +++ b/template/src/Placeholder.ServiceDefaults/Extensions.cs @@ -1,3 +1,4 @@ +using Azure.Monitor.OpenTelemetry.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Diagnostics.HealthChecks; using Microsoft.Extensions.DependencyInjection; @@ -58,7 +59,8 @@ public static IHostApplicationBuilder ConfigureOpenTelemetry(this IHostApplicati // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) //.AddGrpcClientInstrumentation() .AddHttpClientInstrumentation(); - }); + }) + .UseAzureMonitor(); builder.AddOpenTelemetryExporters(); diff --git a/template/src/Placeholder.ServiceDefaults/Placeholder.ServiceDefaults.csproj b/template/src/Placeholder.ServiceDefaults/Placeholder.ServiceDefaults.csproj index 929ca8b..6f81783 100644 --- a/template/src/Placeholder.ServiceDefaults/Placeholder.ServiceDefaults.csproj +++ b/template/src/Placeholder.ServiceDefaults/Placeholder.ServiceDefaults.csproj @@ -9,6 +9,7 @@ +