ExternalServiceBuilderExtensions Methods
AddExternalService(IDistributedApplicationBuilder, string, string) Section titled AddExternalService(IDistributedApplicationBuilder, string, string) extension IResourceBuilder<ExternalServiceResource> public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, string url) { // ... }}Parameters
builder IDistributedApplicationBuilder The distributed application builder. name string The name of the resource. url string The URL of the external service. Returns
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance. AddExternalService(IDistributedApplicationBuilder, string, Uri) Section titled AddExternalService(IDistributedApplicationBuilder, string, Uri) extension IResourceBuilder<ExternalServiceResource> public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, Uri uri) { // ... }}Parameters
builder IDistributedApplicationBuilder The distributed application builder. name string The name of the resource. uri Uri The URI of the external service. Returns
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance. AddExternalService(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>) Section titled AddExternalService(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>) extension IResourceBuilder<ExternalServiceResource> public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, IResourceBuilder<ParameterResource> urlParameter) { // ... }}Parameters
builder IDistributedApplicationBuilder The distributed application builder. name string The name of the resource. urlParameter IResourceBuilder<ParameterResource> The parameter containing the URL of the external service. Returns
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance. WithHttpHealthCheck(IResourceBuilder<ExternalServiceResource>, string?, int?) Section titled WithHttpHealthCheck(IResourceBuilder<ExternalServiceResource>, string?, int?) extension IResourceBuilder<ExternalServiceResource> public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> WithHttpHealthCheck( this IResourceBuilder<ExternalServiceResource> builder, string? path = null, int? statusCode = null) { // ... }}Parameters
builder IResourceBuilder<ExternalServiceResource> The external service resource builder. path string? optional The relative path to use for the HTTP health check. statusCode int? optional The expected HTTP status code for a healthy response. Defaults to 200. Returns
IResourceBuilder<ExternalServiceResource> The ApplicationModel.IResourceBuilder`1 for chaining. Remarks
This method adds a health check to the health check service which polls the specified external service on a periodic basis. The address is based on the URL of the external service. A path for the health check request can be specified. The expected status code is set to 200 by default but a different one can be specified.
When the external service URL is a static ExternalServiceResource.Uri, 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 ExternalServiceResource.UrlParameter, the final address is not known at configuration time. A Hosting.ParameterUriHealthCheck is registered instead; it resolves the parameter with ParameterResource.GetValueAsync on each probe, validates the URL, and then performs the HTTP request.