Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/markdownlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
uses: actions/setup-node@c2ac33f2c62f978d6c944d9648125a294e56dc0b
with:
node-version: 16.x
node-version: 20.x
- name: Run Markdownlint
run: |
echo "::add-matcher::.github/workflows/markdownlint-problem-matcher.json"
Expand Down
26 changes: 24 additions & 2 deletions docs/fundamentals/health-checks.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: .NET Aspire health checks
description: Explore .NET Aspire health checks
ms.date: 12/08/2023
ms.date: 04/02/2024
ms.topic: quickstart
---

Expand All @@ -15,7 +15,7 @@ Health checks provide availability and state information about an app. Health ch

## .NET Aspire health check endpoints

.NET Aspire exposes two default health check HTTP endpoints when the `AddServiceDefaults` and `MapDefaultEndpoints` methods are called from the _Program.cs_ file:
.NET Aspire exposes two default health check HTTP endpoints in **Development** environments when the `AddServiceDefaults` and `MapDefaultEndpoints` methods are called from the _Program.cs_ file:

- The `/health` endpoint indicates if the app is running normally where it's ready to receive requests. All health checks must pass for app to be considered ready to accept traffic after starting.

Expand All @@ -35,6 +35,28 @@ Health checks provide availability and state information about an app. Health ch

The `AddServiceDefaults` and `MapDefaultEndpoints` methods also apply various configurations to your app beyond just health checks, such as OpenTelemetry and service discovery configurations.

### Non-development environments

In non-development environments, the `/health` and `/alive` endpoints are disabled by default. If you need to enable them, its recommended to protect these endpoints with various routing features, such as host filtering and/or authorization. For more information, see [Health checks in ASP.NET Core](/aspnet/core/host-and-deploy/health-checks#use-health-checks-routing).

Additionally, it may advantageous to configure request timeouts and output caching for these endpoints to prevent abuse or denial-of-service attacks. To do so, consider the following modified `AddDefaultHealthChecks` method:

:::code language="csharp" source="snippets/healthz/Healthz.ServiceDefaults/Extensions.cs" id="healthchecks":::

The preceding code:

- Adds a timeout of 5 seconds to the health check requests with a policy named `HealthChecks`.
- Adds a 10-second cache to the health check responses with a policy named `HealthChecks`.

Now consider the updated `MapDefaultEndpoints` method:

:::code language="csharp" source="snippets/healthz/Healthz.ServiceDefaults/Extensions.cs" id="mapendpoints":::

The preceding code:

- Groups the health check endpoints under the `/` path.
- Caches the output and specifies a request time with the corresponding `HealthChecks` policy.

## Component health checks

.NET Aspire components can also register additional health checks for your app. These health checks contribute to the returned status of the `/health` and `/alive` endpoints. For example, the .NET Aspire PostgreSQL component automatically adds a health check to verify the following conditions:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace Microsoft.Extensions.Hosting;

public static class Extensions
{
public static IHostApplicationBuilder AddServiceDefaults(this IHostApplicationBuilder builder)
{
builder.AddDefaultHealthChecks();

return builder;
}

// <healthchecks>
public static IHostApplicationBuilder AddDefaultHealthChecks(this IHostApplicationBuilder builder)
{
builder.Services.AddRequestTimeouts(
configure: static timeouts =>
timeouts.AddPolicy("HealthChecks", TimeSpan.FromSeconds(5)));

builder.Services.AddOutputCache(
configureOptions: static caching =>
caching.AddPolicy("HealthChecks",
build: static policy => policy.Expire(TimeSpan.FromSeconds(10))));

builder.Services.AddHealthChecks()
// Add a default liveness check to ensure app is responsive
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

return builder;
}
// </healthchecks>

// <mapendpoints>
public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
var healthChecks = app.MapGroup("");

healthChecks
.CacheOutput("HealthChecks")
.WithRequestTimeout("HealthChecks");

// All health checks must pass for app to be
// considered ready to accept traffic after starting
healthChecks.MapHealthChecks("/health");

// Only health checks tagged with the "live" tag
// must pass for app to be considered alive
healthChecks.MapHealthChecks("/alive", new()
{
Predicate = static r => r.Tags.Contains("live")
});

return app;
}
// </mapendpoints>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="8.2.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.0-preview.4.24156.9" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.7.0-beta.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.7.1" />
<PackageReference Include="OpenTelemetry.Instrumentation.Process" Version="0.5.0-beta.4" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.7.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34727.303
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Healthz.ServiceDefaults", "Healthz.ServiceDefaults.csproj", "{489CF15E-6758-4CD5-80B7-DD698ED2D964}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{489CF15E-6758-4CD5-80B7-DD698ED2D964}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{489CF15E-6758-4CD5-80B7-DD698ED2D964}.Debug|Any CPU.Build.0 = Debug|Any CPU
{489CF15E-6758-4CD5-80B7-DD698ED2D964}.Release|Any CPU.ActiveCfg = Release|Any CPU
{489CF15E-6758-4CD5-80B7-DD698ED2D964}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B445EE8B-3BD1-4F13-A5BB-DE20505966D9}
EndGlobalSection
EndGlobal
37 changes: 23 additions & 14 deletions docs/whats-new/preview-5.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,45 @@
---
title: .NET Aspire preview 5
description: .NET Aspire preview 5 is now available and includes many improvements and new capabilities
ms.date: 03/28/2024
ms.date: 04/02/2024
---

# .NET Aspire preview 5

Breaking Changes
- The major package split, Aspire.* and Aspire.Hosting.*

- The major package split, Aspire.*and Aspire.Hosting.*
- AppHost projects now need to reference Aspire.Hosting.AppHost
- Each resource was split into individual packages
- Aspire.Hosting.Redis
- Aspire.Hosting.PostgreSQL
- Aspire.Hosting.MongoDB
- Aspire.Hosting.RabbitMQ
- etc.
- Aspire.Hosting.Redis
- Aspire.Hosting.PostgreSQL
- Aspire.Hosting.MongoDB
- Aspire.Hosting.RabbitMQ
- etc.
- The same applies to the Azure resources
- Aspire.Hosting.Azure.Redis (etc)
- Aspire.Hosting.Azure.Redis (etc)
- Async all the things, various callbacks in the app model APIs
are now async. (GetConnectionStringAsync etc.)

Dashboard
- Support for authentication

- Support for authentication
- OTLP
- UI (Frontend)
- LOTS of performance improvements
- Console log virtualization
- Load time improvements
- Trace ingestion improvements
- Console log virtualization
- Load time improvements
- Trace ingestion improvements
- Run on a single port (OTLP and UI)
- Standalone container now forces you to choose auth

Templates

- HTTPs by default
- Test project support

AppModel

- Forwarded headers enabled by default for projects with endpoints
- Custom resources support in dashboard
- Can publish notifications to the dashboard
Expand All @@ -47,36 +51,41 @@ AppModel
- Support for composing environment variables using string interpolation
that can capture resource properties. (ReferenceExpression, WithEnvironment overload)


Service Discovery

- Service discovery API changes
- Service discovery auto scheme detection

Tooling

- VS Code support
- Prompting for parameters in Visual Studio

Components

- Azure Events Hubs
- Renamed all of the methods to end with *Client e.g. AddRedisClient
- Nats OpenTelemetry support

Azure

- Azure CDK Support (introducing the new Azure CDK)
- All Azure resources were refactored to use the CDK
- Azure Provisioning for Development
- Azure OpenAI provisioning

Manifest

- Express container volumes and bindmounts in the manifest
- Support for multiple endpoints in the manifest
- Renamed containerPort to targetPort
- Added port as the "exposed port"

Azure Deployment

- Service selection prompt gone (WithExternalHttpEndpoints in apphost)
- Support for multiple endpoints in ACA
- Support for adding volumes to containers in ACA

- IDE protocol changes
- There's a new IDE protcol
- There's a new IDE protcol