Support specific external connection string
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe.
Aspire currently provides `AddConnectionString`, but it is a generic abstraction that requires consumers to either:
- provide a fully-formed connection string, or
- manually build the connection string using `ReferenceExpression`s.
This creates unnecessary duplication because resource-specific hosting packages such as `Aspire.Hosting.SqlServer`, `Aspire.Hosting.PostgreSQL`, and `Aspire.Hosting.Redis` already contain the logic required to generate provider-specific connection strings in their supported formats (ADO.NET, URI, JDBC, etc.).
As a result, users cannot easily leverage that existing logic when defining standalone `ConnectionStringResource`s, and they lose access to resource-specific metadata and integrations.
### Describe the solution you'd like
Introduce provider-specific helpers for creating connection string resources, for example:
```csharp
IResourceBuilder AddSqlServerConnectionString(
string name,
EndpointReference host,
ReferenceExpression username,
ReferenceExpression password);
IResourceBuilder AddPostgresSqlConnectionString(
string name,
EndpointReference host,
ReferenceExpression username,
ReferenceExpression password);
IResourceBuilder AddRedisConnectionString(
string name,
EndpointReference host,
ReferenceExpression password);
```
These APIs would:
- Reuse the same connection string generation logic already implemented by the corresponding Aspire hosting packages.
- Support provider-specific formats where applicable (ADO.NET, URI, JDBC, etc.).- Integrate with `GetConnectionProperties()`.
- Enable provider-specific health checks and metadata.
- Reduce duplication and improve consistency between resource definitions and generated connection strings.
Contributor guide
Research direction
Start by comparing AddConnectionString with the provider-specific logic in Aspire.Hosting.SqlServer, Aspire.Hosting.PostgreSQL, and Aspire.Hosting.Redis. Trace how GetConnectionProperties() and existing connection-string generation are exposed; done means the proposed provider-specific helpers support the listed formats, metadata, integrations, and health checks consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, postgresql, redis, sql
- Domain
- api, backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100