# ExternalServiceResource Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [ExternalServiceResource](/reference/api/csharp/aspire.hosting/externalserviceresource.md)
- Kind: `Constructors`
- Members: `2`

Represents an external service resource with service discovery capabilities.

## ExternalServiceResource(string, Uri)

- Name: `Constructor(string, Uri)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ExternalServiceResource.cs#L26-L34)

Creates a new instance of [ExternalServiceResource](/reference/api/csharp/aspire.hosting/externalserviceresource.md) with a specified name and URI.

```csharp
public sealed class ExternalServiceResource
{
    public ExternalServiceResource(
        string name,
        Uri uri)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `uri` (`Uri`)
  The URI for the external service.

## Remarks

The URI must be an absolute URI with the absolute path ending with '/'. The URI cannot contain a fragment or query string.

## ExternalServiceResource(string, ParameterResource)

- Name: `Constructor(string, ParameterResource)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ExternalServiceResource.cs#L41-L44)

Creates a new instance of [ExternalServiceResource](/reference/api/csharp/aspire.hosting/externalserviceresource.md) with a specified name and URL parameter.

```csharp
public sealed class ExternalServiceResource
{
    public ExternalServiceResource(
        string name,
        ParameterResource urlParameter)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource.
- `urlParameter` ([ParameterResource](/reference/api/csharp/aspire.hosting/parameterresource.md))
  The parameter to use for the URL of the external service.
