File tree Expand file tree Collapse file tree 3 files changed +38
-23
lines changed
src/Aspire.ProjectTemplates/templates
aspire-empty/AspireApplication.1.ServiceDefaults
aspire-starter/AspireStarterApplication.1.ServiceDefaults Expand file tree Collapse file tree 3 files changed +38
-23
lines changed Original file line number Diff line number Diff line change @@ -101,17 +101,22 @@ public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicati
101101
102102 public static WebApplication MapDefaultEndpoints ( this WebApplication app )
103103 {
104- // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
105- // app.MapPrometheusScrapingEndpoint();
104+ // Adding health checks endpoints to applications in non-development environments has security implications.
105+ // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
106+ if ( app . Environment . IsDevelopment ( ) )
107+ {
108+ // All health checks must pass for app to be considered ready to accept traffic after starting
109+ app . MapHealthChecks ( "/health" ) ;
106110
107- // All health checks must pass for app to be considered ready to accept traffic after starting
108- app . MapHealthChecks ( "/health" ) ;
111+ // Only health checks tagged with the "live" tag must pass for app to be considered alive
112+ app . MapHealthChecks ( "/alive" , new HealthCheckOptions
113+ {
114+ Predicate = r => r . Tags . Contains ( "live" )
115+ } ) ;
109116
110- // Only health checks tagged with the "live" tag must pass for app to be considered alive
111- app . MapHealthChecks ( "/alive" , new HealthCheckOptions
112- {
113- Predicate = r => r . Tags . Contains ( "live" )
114- } ) ;
117+ // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
118+ // app.MapPrometheusScrapingEndpoint();
119+ }
115120
116121 return app ;
117122 }
Original file line number Diff line number Diff line change @@ -111,14 +111,19 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
111111 // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
112112 // app.MapPrometheusScrapingEndpoint();
113113
114- // All health checks must pass for app to be considered ready to accept traffic after starting
115- app . MapHealthChecks ( "/health" ) ;
116-
117- // Only health checks tagged with the "live" tag must pass for app to be considered alive
118- app . MapHealthChecks ( "/alive" , new HealthCheckOptions
114+ // Adding health checks endpoints to applications in non-development environments has security implications.
115+ // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
116+ if ( app . Environment . IsDevelopment ( ) )
119117 {
120- Predicate = r => r . Tags . Contains ( "live" )
121- } ) ;
118+ // All health checks must pass for app to be considered ready to accept traffic after starting
119+ app . MapHealthChecks ( "/health" ) ;
120+
121+ // Only health checks tagged with the "live" tag must pass for app to be considered alive
122+ app . MapHealthChecks ( "/alive" , new HealthCheckOptions
123+ {
124+ Predicate = r => r . Tags . Contains ( "live" )
125+ } ) ;
126+ }
122127
123128 return app ;
124129 }
Original file line number Diff line number Diff line change @@ -104,14 +104,19 @@ public static WebApplication MapDefaultEndpoints(this WebApplication app)
104104 // Uncomment the following line to enable the Prometheus endpoint (requires the OpenTelemetry.Exporter.Prometheus.AspNetCore package)
105105 // app.MapPrometheusScrapingEndpoint();
106106
107- // All health checks must pass for app to be considered ready to accept traffic after starting
108- app . MapHealthChecks ( "/health" ) ;
109-
110- // Only health checks tagged with the "live" tag must pass for app to be considered alive
111- app . MapHealthChecks ( "/alive" , new HealthCheckOptions
107+ // Adding health checks endpoints to applications in non-development environments has security implications.
108+ // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
109+ if ( app . Environment . IsDevelopment ( ) )
112110 {
113- Predicate = r => r . Tags . Contains ( "live" )
114- } ) ;
111+ // All health checks must pass for app to be considered ready to accept traffic after starting
112+ app . MapHealthChecks ( "/health" ) ;
113+
114+ // Only health checks tagged with the "live" tag must pass for app to be considered alive
115+ app . MapHealthChecks ( "/alive" , new HealthCheckOptions
116+ {
117+ Predicate = r => r . Tags . Contains ( "live" )
118+ } ) ;
119+ }
115120
116121 return app ;
117122 }
You can’t perform that action at this time.
0 commit comments