Surface health check restrictions with MapWhen (#13248)
parent
42bbe27c25
commit
17692fc812
|
@ -327,7 +327,7 @@ To activate environment variables configuration, call the <xref:Microsoft.Extens
|
|||
|
||||
[Azure App Service](https://azure.microsoft.com/services/app-service/) permits you to set environment variables in the Azure Portal that can override app configuration using the Environment Variables Configuration Provider. For more information, see [Azure Apps: Override app configuration using the Azure Portal](xref:host-and-deploy/azure-apps/index#override-app-configuration-using-the-azure-portal).
|
||||
|
||||
`AddEnvironmentVariables` is used to load environment variables prefixed with `ASPNETCORE_` for [host configuration](#host-vs-app-configuration) when a new <xref:Microsoft.AspNetCore.Hosting.WebHostBuilder> is initialized. For more information, see [Web Host: Set up a host](xref:fundamentals/host/web-host#set-up-a-host).
|
||||
`AddEnvironmentVariables` is used to load environment variables prefixed with `ASPNETCORE_` for [host configuration](#host-versus-app-configuration) when a new <xref:Microsoft.AspNetCore.Hosting.WebHostBuilder> is initialized. For more information, see [Web Host: Set up a host](xref:fundamentals/host/web-host#set-up-a-host).
|
||||
|
||||
`CreateDefaultBuilder` also loads:
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Learn how to set up health checks for ASP.NET Core infrastructure,
|
|||
monikerRange: '>= aspnetcore-2.2'
|
||||
ms.author: riande
|
||||
ms.custom: mvc
|
||||
ms.date: 04/23/2019
|
||||
ms.date: 07/11/2019
|
||||
uid: host-and-deploy/health-checks
|
||||
---
|
||||
# Health checks in ASP.NET Core
|
||||
|
@ -678,3 +678,20 @@ In the sample app's `LivenessProbeStartup` example, the `StartupHostedService` r
|
|||
> [AspNetCore.Diagnostics.HealthChecks](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks) includes publishers for several systems, including [Application Insights](/azure/application-insights/app-insights-overview).
|
||||
>
|
||||
> [AspNetCore.Diagnostics.HealthChecks](https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks) is a port of [BeatPulse](https://github.com/xabaril/beatpulse) and isn't maintained or supported by Microsoft.
|
||||
|
||||
## Restrict health checks with MapWhen
|
||||
|
||||
Use <xref:Microsoft.AspNetCore.Builder.MapWhenExtensions.MapWhen*> to conditionally branch the request pipeline for health check endpoints.
|
||||
|
||||
In the following example, `MapWhen` branches the request pipeline to activate Health Check Middleware if a GET request is received for the `api/HealthCheck` endpoint:
|
||||
|
||||
```csharp
|
||||
app.MapWhen(
|
||||
context => context.Request.Method == HttpMethod.Get.Method &&
|
||||
context.Request.Path.StartsWith("/api/HealthCheck"),
|
||||
builder => builder.UseHealthChecks());
|
||||
|
||||
app.UseMvc();
|
||||
```
|
||||
|
||||
For more information, see <xref:fundamentals/middleware/index#use-run-and-map>.
|
||||
|
|
Loading…
Reference in New Issue