ExternalServiceBuilderExtensions Methods
AddExternalService(IDistributedApplicationBuilder, string, string)Section titled AddExternalService(IDistributedApplicationBuilder, string, string)extensionIResourceBuilder<ExternalServiceResource>public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, string url) { // ... }}Parameters
builderIDistributedApplicationBuilderThe distributed application builder.namestringThe name of the resource.urlstringThe URL of the external service.Returns
IResourceBuilder<ExternalServiceResource>An ApplicationModel.IResourceBuilder`1 instance.AddExternalService(IDistributedApplicationBuilder, string, Uri)Section titled AddExternalService(IDistributedApplicationBuilder, string, Uri)extensionIResourceBuilder<ExternalServiceResource>public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, Uri uri) { // ... }}Parameters
builderIDistributedApplicationBuilderThe distributed application builder.namestringThe name of the resource.uriUriThe 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>)extensionIResourceBuilder<ExternalServiceResource>public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> AddExternalService( this IDistributedApplicationBuilder builder, string name, IResourceBuilder<ParameterResource> urlParameter) { // ... }}Parameters
builderIDistributedApplicationBuilderThe distributed application builder.namestringThe name of the resource.urlParameterIResourceBuilder<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?)extensionIResourceBuilder<ExternalServiceResource>public static class ExternalServiceBuilderExtensions{ public static IResourceBuilder<ExternalServiceResource> WithHttpHealthCheck( this IResourceBuilder<ExternalServiceResource> builder, string? path = null, int? statusCode = null) { // ... }}Parameters
builderIResourceBuilder<ExternalServiceResource>The external service resource builder.pathstring?optionalThe relative path to use for the HTTP health check.statusCodeint?optionalThe 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.