Skip to content
Docs Try Aspire

ExternalServiceBuilderExtensions Methods

Class Methods 4 members
Provides extension methods for adding external services to an application.
AddExternalService(IDistributedApplicationBuilder, string, string) Section titled AddExternalService(IDistributedApplicationBuilder, string, string) extension IResourceBuilder<ExternalServiceResource>
Adds an external service resource to the distributed application with the specified URL.
public static class ExternalServiceBuilderExtensions
{
public static IResourceBuilder<ExternalServiceResource> AddExternalService(
this IDistributedApplicationBuilder builder,
string name,
string url)
{
// ...
}
}
builder IDistributedApplicationBuilder The distributed application builder.
name string The name of the resource.
url string The URL of the external service.
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance.
AddExternalService(IDistributedApplicationBuilder, string, Uri) Section titled AddExternalService(IDistributedApplicationBuilder, string, Uri) extension IResourceBuilder<ExternalServiceResource>
Adds an external service resource to the distributed application with the specified URI.
public static class ExternalServiceBuilderExtensions
{
public static IResourceBuilder<ExternalServiceResource> AddExternalService(
this IDistributedApplicationBuilder builder,
string name,
Uri uri)
{
// ...
}
}
builder IDistributedApplicationBuilder The distributed application builder.
name string The name of the resource.
uri Uri The URI of the external service.
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance.
AddExternalService(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>) Section titled AddExternalService(IDistributedApplicationBuilder, string, IResourceBuilder<ParameterResource>) extension IResourceBuilder<ExternalServiceResource>
Adds an external service resource to the distributed application with the URL coming from the specified parameter.
public static class ExternalServiceBuilderExtensions
{
public static IResourceBuilder<ExternalServiceResource> AddExternalService(
this IDistributedApplicationBuilder builder,
string name,
IResourceBuilder<ParameterResource> urlParameter)
{
// ...
}
}
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.
IResourceBuilder<ExternalServiceResource> An ApplicationModel.IResourceBuilder`1 instance.
WithHttpHealthCheck(IResourceBuilder<ExternalServiceResource>, string?, int?) Section titled WithHttpHealthCheck(IResourceBuilder<ExternalServiceResource>, string?, int?) extension IResourceBuilder<ExternalServiceResource>
Adds a health check to the external service resource.
public static class ExternalServiceBuilderExtensions
{
public static IResourceBuilder<ExternalServiceResource> WithHttpHealthCheck(
this IResourceBuilder<ExternalServiceResource> builder,
string? path = null,
int? statusCode = null)
{
// ...
}
}
builder IResourceBuilder<ExternalServiceResource>
path string? optional The relative path to use for the HTTP health check.
statusCode int? optional

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.