# IResourceWithConnectionString

- Kind: `interface`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/IResourceWithConnectionString.cs)
- Implements: [IExpressionValue](/reference/api/csharp/aspire.hosting/iexpressionvalue.md), [IManifestExpressionProvider](/reference/api/csharp/aspire.hosting/imanifestexpressionprovider.md), [IResource](/reference/api/csharp/aspire.hosting/iresource.md), [IValueProvider](/reference/api/csharp/aspire.hosting/ivalueprovider.md), [IValueWithReferences](/reference/api/csharp/aspire.hosting/ivaluewithreferences.md)

Represents a resource that has a connection string associated with it.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public interface IResourceWithConnectionString
    : Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences
{
    // ...
}
```

## Properties

- [ConnectionStringEnvironmentVariable](/reference/api/csharp/aspire.hosting/iresourcewithconnectionstring/properties.md#connectionstringenvironmentvariable) : `string?` `virtual` `get` -- The environment variable name to use for the connection string.
- [ConnectionStringExpression](/reference/api/csharp/aspire.hosting/iresourcewithconnectionstring/properties.md#connectionstringexpression) : [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md) `abstract` `get` -- Describes the connection string format string used for this resource.

## Methods

- [GetConnectionProperties](/reference/api/csharp/aspire.hosting/iresourcewithconnectionstring/methods.md#getconnectionproperties) : `IEnumerable<KeyValuePair<string, ReferenceExpression>>` `virtual` -- Retrieves a collection of connection property name and value pairs associated with the current context.
- [GetConnectionStringAsync(CancellationToken)](/reference/api/csharp/aspire.hosting/iresourcewithconnectionstring/methods.md#getconnectionstringasync-cancellationtoken) : `ValueTask<string?>` `virtual` -- Gets the connection string associated with the resource.
