# K3sServiceEndpointResource Methods

- Package: [CommunityToolkit.Aspire.Hosting.K3s](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s.md)
- Type: [K3sServiceEndpointResource](/reference/api/csharp/communitytoolkit.aspire.hosting.k3s/k3sserviceendpointresource.md)
- Kind: `Methods`
- Members: `1`

Represents a Kubernetes Service exposed from a k3s cluster as an Aspire endpoint resource.

<a id="getconnectionstringasync"></a>
<a id="getconnectionstringasync-cancellationtoken"></a>

## GetConnectionStringAsync(CancellationToken)

- Name: `GetConnectionStringAsync(CancellationToken)`
- Returns: `ValueTask<string?>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/d479e13473b1d29d06b974f144a0049289a3cb5c/src/CommunityToolkit.Aspire.Hosting.K3s/K3sServiceEndpointResource.cs#L103-L106)

Returns the host-accessible service URL, or `null` if the port-forward is not yet active.

```csharp
public sealed class K3sServiceEndpointResource
{
    public ValueTask<string?> GetConnectionStringAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`

## Remarks

Returns `null` until the endpoint transitions to `Running`. Declare `WaitFor(endpoint)` on dependent resources so that this value is always populated by the time their environment variables are evaluated.
