Skip to content

Cannot WaitFor ExternalService resources #10827

@julioct

Description

@julioct

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Aspire resources cannot wait for external services, so they will start even if the external service reports an unhealthy status:

var builder = DistributedApplication.CreateBuilder(args);

var externalApi = builder.AddExternalService("backend-api", "http://localhost:5082")
                        .WithHttpHealthCheck("/health/ready");

builder.AddProject<BlazorApp1>("frontend")
        .WaitFor(externalApi); // Won't wait

builder.Build().Run();
Image

Expected Behavior

Any resource that waits on an external service, where that external service includes a health check, should not start until the external service is healthy.

Steps To Reproduce

  1. Create a new Aspire application with an external service resource (does not even need to exist) and a vanilla Blazor project that waits for the external service:
var builder = DistributedApplication.CreateBuilder(args);

var externalApi = builder.AddExternalService("backend-api", "http://localhost:5082")
                        .WithHttpHealthCheck("/health/ready");

builder.AddProject<BlazorApp1>("frontend")
        .WaitFor(externalApi);

builder.Build().Run();
  1. Ensure the external service is not running at all
  2. Start the Aspire AppHost
  3. Go to the Aspire dashboard
  4. The external service reports Running (Unhealthy) state
  5. The frontend, however, entered Running state
Image

Exceptions (if any)

No response

.NET Version info

.NET SDK:
Version: 9.0.303
Commit: 5d97611193
Workload version: 9.0.300-manifests.fadeff71
MSBuild version: 17.14.13+65391c53b

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.303\

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
Version: 9.0.7
Architecture: x64
Commit: 3c298d9f00

.NET SDKs installed:
8.0.412 [C:\Program Files\dotnet\sdk]
9.0.303 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
None

Environment variables:
Not set

global.json file:
Not found

Anything else?

.NET Aspire version: 9.4
IDE: VS Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-integrationsIssues pertaining to Aspire Integrations packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions