# AllocatedEndpoint Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md)
- Kind: `Constructors`
- Members: `3`

Represents an endpoint allocated for a service instance.

## AllocatedEndpoint(EndpointAnnotation, string, int, EndpointBindingMode, string?, NetworkIdentifier?)

- Name: `Constructor(EndpointAnnotation, string, int, EndpointBindingMode, string?, NetworkIdentifier?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs#L49-L67)

Initializes a new instance of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) class.

```csharp
public class AllocatedEndpoint
{
    public AllocatedEndpoint(
        EndpointAnnotation endpoint,
        string address,
        int port,
        EndpointBindingMode bindingMode,
        string? targetPortExpression = null,
        NetworkIdentifier? networkID = null)
    {
        // ...
    }
}
```

## Parameters

- `endpoint` ([EndpointAnnotation](/reference/api/csharp/aspire.hosting/endpointannotation.md))
  The endpoint.
- `address` (`string`)
  The IP address of the endpoint.
- `port` (`int`)
  The port number of the endpoint.
- `bindingMode` ([EndpointBindingMode](/reference/api/csharp/aspire.hosting/endpointbindingmode.md))
  The binding mode of the endpoint.
- `targetPortExpression` (`string?`) `optional`
  A string representing how to retrieve the target port of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) instance.
- `networkID` ([NetworkIdentifier?](/reference/api/csharp/aspire.hosting/networkidentifier.md)) `optional`
  The network identifier for the network associated with the endpoint.

## AllocatedEndpoint(EndpointAnnotation, string, int, EndpointBindingMode, string?)

- Name: `Constructor(EndpointAnnotation, string, int, EndpointBindingMode, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs#L82-L84)

Initializes a new instance of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) class.

```csharp
public class AllocatedEndpoint
{
    public AllocatedEndpoint(
        EndpointAnnotation endpoint,
        string address,
        int port,
        EndpointBindingMode bindingMode,
        string? targetPortExpression = null)
    {
        // ...
    }
}
```

## Parameters

- `endpoint` ([EndpointAnnotation](/reference/api/csharp/aspire.hosting/endpointannotation.md))
  The endpoint.
- `address` (`string`)
  The IP address of the endpoint.
- `port` (`int`)
  The port number of the endpoint.
- `bindingMode` ([EndpointBindingMode](/reference/api/csharp/aspire.hosting/endpointbindingmode.md))
  The binding mode of the endpoint.
- `targetPortExpression` (`string?`) `optional`
  A string representing how to retrieve the target port of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) instance.

## AllocatedEndpoint(EndpointAnnotation, string, int, string?)

- Name: `Constructor(EndpointAnnotation, string, int, string?)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/AllocatedEndpoint.cs#L94-L96)

Initializes a new instance of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) class.

```csharp
public class AllocatedEndpoint
{
    public AllocatedEndpoint(
        EndpointAnnotation endpoint,
        string address,
        int port,
        string? targetPortExpression = null)
    {
        // ...
    }
}
```

## Parameters

- `endpoint` ([EndpointAnnotation](/reference/api/csharp/aspire.hosting/endpointannotation.md))
  The endpoint.
- `address` (`string`)
  The IP address of the endpoint.
- `port` (`int`)
  The port number of the endpoint.
- `targetPortExpression` (`string?`) `optional`
  A string representing how to retrieve the target port of the [AllocatedEndpoint](/reference/api/csharp/aspire.hosting/allocatedendpoint.md) instance.
