diff --git a/src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs b/src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs index 3ffe150dfed..a82f86077a0 100644 --- a/src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs +++ b/src/Aspire.Hosting/ExternalServiceBuilderExtensions.cs @@ -203,6 +203,16 @@ static ImmutableArray AddUrlIfNotPresent(ImmutableArray200 by default but a /// different one can be specified. /// + /// + /// When the external service URL is a static , the health check is registered + /// with AddUrlGroup at configuration time and the HTTP or HTTPS scheme is validated when this method is called. + /// + /// + /// When the URL comes from a , the final address is not known at + /// configuration time. A is registered instead; it resolves the parameter with + /// on each probe, validates the URL, and then performs + /// the HTTP request. + /// /// [AspireExportIgnore(Reason = "Polyglot app hosts use the internal withHttpHealthCheck export wrapper.")] public static IResourceBuilder WithHttpHealthCheck(this IResourceBuilder builder, string? path = null, int? statusCode = null) @@ -224,6 +234,8 @@ public static IResourceBuilder WithHttpHealthCheck(this } } + Debug.Assert(builder.Resource.Uri is not null || builder.Resource.UrlParameter is not null, "Either Uri or UrlParameter must be provided."); + statusCode ??= 200; var pathKey = path is not null ? $"_{path}" : string.Empty;