-
Notifications
You must be signed in to change notification settings - Fork 733
Implement Connection Properties and supporting expressions #11938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7c72c7b
Introduce IResourceWithProperties
sebastienros 21972f0
Take 2
sebastienros 03c37b5
Support formats in ReferenceExpression
sebastienros 858f6d4
Add ReferenceEnvironmentInjectionAnnotation
sebastienros bccee3d
Add common connection properties
sebastienros 700f0ec
Add JDBC connection strings
sebastienros 4154e0d
More resource comments
sebastienros 3e33c1e
More resources
sebastienros aa5706e
Merge remote-tracking branch 'origin/main' into sebros/properties
sebastienros 6689f8a
Fix some tests
sebastienros 1e191c5
Verify Garnet, GH Models, Milvus,
sebastienros 7d9dbdb
Verify more resources
sebastienros e02272b
Fix test
sebastienros 95311a0
Fix breaking changes
sebastienros ac0397f
Update Node sample
sebastienros 84ecae4
Revert Postgres playground
sebastienros 5111376
Add connection properties docs
sebastienros 50a28e6
Fix markdown linter errors
sebastienros 0b160f7
Add extension method to configure connection properties on resources
sebastienros aa102a2
Add more tests
sebastienros 9bbbd77
Fix test
sebastienros fdd090e
Update src/Aspire.Hosting/ApplicationModel/ReferenceExpression.cs
sebastienros 0139957
Fixes
sebastienros 18198d7
Fix deployment
sebastienros 51d00e5
Merge branch 'sebros/properties' of https://github.com/dotnet/aspire …
sebastienros 462ba39
Merge remote-tracking branch 'origin/main' into sebros/properties
sebastienros e7a6d75
PR feedback
sebastienros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| # Connection Properties | ||
| > Audience - Aspire contributors and integration authors implementing or consuming `IResourceWithConnectionString` resources. | ||
|
|
||
| ## Overview | ||
| - `IResourceWithConnectionString.GetConnectionProperties()` returns a stable set of well known keys mapped to `ReferenceExpression` values that are then injected as environment variables in select resources. | ||
| - Keys describe connection metadata beyond the raw connection string so dependent resources can access specific pieces (via `GetConnectionProperty` or environment splatting). | ||
| - Keys are emitted in PascalCase; lookups are case insensitive and duplicates should be avoided. | ||
| - `WithReference(..., ReferenceEnvironmentInjectionFlags.ConnectionProperties)` splats every key as an environment variable using the reference name prefix and an uppercased key (for example `POSTGRES_HOST`). | ||
|
|
||
| ## Common Behavior | ||
| - Prefer short, technology neutral names when one value is broadly useful (`Host`, `Port`, `Uri`). | ||
| - Use explicit prefixes only when a resource exposes multiple endpoints (`GrpcHost`, `HttpHost`). | ||
| - Child resources (`*DatabaseResource`, `OpenAIModelResource`) typically return the parent set plus a small overlay using `Union` so downstream callers see both shared and resource specific keys. | ||
| - When adding a new resource, surface the minimal property set needed for common configurations. | ||
|
|
||
| ## Property Catalog | ||
|
|
||
| ### Network Identity | ||
|
|
||
| | Key | Description | Provided By | Notes | | ||
| | --- | --- | --- | --- | | ||
| | Host | Primary hostname or address for the resource. | PostgreSQL, MySQL, SQL Server, Oracle, Redis, Garnet, Valkey, RabbitMQ, NATS, Kafka, MongoDB, Milvus. | Derived from `EndpointProperty.Host` of the primary endpoint. | | ||
| | Port | Primary TCP port number. | Same set as `Host`. | Derived from `EndpointProperty.Port`. | | ||
|
|
||
| ### URIs and URLs | ||
|
|
||
| | Key | Description | Provided By | Notes | | ||
| | --- | --- | --- | --- | | ||
| | Uri | Service specific URI built from host, port, credentials, and scheme. | PostgreSQL, PostgresDatabase, MySQL, MySqlDatabase, Redis, Garnet, Valkey, RabbitMQ, NATS, Seq, MongoDBDatabase, Milvus, Qdrant (gRPC), GitHubModel, OpenAI. | Formatting rules per resource are listed in [URI Construction](#uri-construction). | | ||
|
|
||
| ### Credentials and Secrets | ||
|
|
||
| | Key | Description | Provided By | Notes | | ||
| | --- | --- | --- | --- | | ||
| | Username | Login user for the primary endpoint. | PostgreSQL, MySQL, SQL Server, Oracle, RabbitMQ, NATS, MongoDB. | Defaults align with respective containers (`postgres`, `root`, `sa`, etc.). | | ||
| | Password | Login password. | PostgreSQL, MySQL, SQL Server, Oracle, Redis (when configured), Garnet (when configured), Valkey (when configured), RabbitMQ, NATS (when configured). | Omitted when the resource does not manage credentials. | | ||
| | Key | API key or token parameter. | OpenAI, GitHubModel, Qdrant. | For GitHub Models the key is a PAT or minted token. | | ||
|
|
||
| ### Database Specific Metadata | ||
|
|
||
| | Key | Description | Provided By | Notes | | ||
| | --- | --- | --- | --- | | ||
| | Database | Logical database name associated with the resource. | PostgresDatabase, MySqlDatabase, SqlServerDatabase, OracleDatabase, MongoDBDatabase, MilvusDatabase. | Added on top of the parent server keys. | | ||
| | JdbcConnectionString | JDBC compatible connection string. | PostgreSQL, PostgresDatabase, MySQL, MySqlDatabase, SQL Server, SqlServerDatabase, Oracle, OracleDatabase. | Formats vary per vendor; see [JDBC Formats](#jdbc-formats). | | ||
|
|
||
| ## URI Construction | ||
|
|
||
| URIs as convey connection information in a generic format that is commonly used by client SDKs. It follows the following pattern: `{SCHEME}://[[USERNAME]:[PASSWORD]@]{HOST}:{PORT}[/{RESOURCE}]` | ||
|
|
||
| URI components should be url-encoded to prevent parsing issues. This is important as components like the password may contain conflicting characters. | ||
|
|
||
| - PostgreSQL server: `postgresql://{Username}:{Password}@{Host}:{Port}` (database resources append `/{Database}`). | ||
| - MySQL server: `mysql://{Username}:{Password}@{Host}:{Port}` (database resources append `/{Database}`). | ||
| - Redis, Garnet, Valkey: `{scheme}://[:{Password}@]{Host}:{Port}` where the scheme matches the resource (`redis`, `valkey`). | ||
| - RabbitMQ: `amqp://{Username}:{Password}@{Host}:{Port}`; `ManagementUri` uses HTTP(S) per endpoint configuration. | ||
| - NATS: `nats://[Username:Password@]{Host}:{Port}` with credentials omitted when absent. | ||
| - MongoDB database: `mongodb://[Username:Password@]{Host}:{Port}/{Database}` with optional `?authSource` and `authMechanism` query string when credentials are present. | ||
| - Milvus: `http(s)://{Host}:{Port}` produced from the primary endpoint; credentials are exposed via the `Token` property. | ||
|
|
||
| All URIs are composed with `:uri` formatting to ensure values are escaped correctly when rendered at deploy time. | ||
|
|
||
| ## JDBC Formats | ||
|
|
||
| - PostgreSQL: `jdbc:postgresql://{Host}:{Port}[/{Database}]` (database resources append the database segment). | ||
| - MySQL: `jdbc:mysql://{Host}:{Port}[/{Database}]?user={Username}&password={Password}`. | ||
| - SQL Server: `jdbc:sqlserver://{Host}:{Port};user={Username};password={Password};trustServerCertificate=true[;databaseName={Database}]`. | ||
| - Oracle: `jdbc:oracle:thin:{Username}/{Password}@//{Host}:{Port}[/{Database}]`. | ||
|
|
||
| ## Implementation Guidance | ||
|
|
||
| - Reuse existing key names whenever possible; introduce new keys only for data that is unique or disambiguates multiple endpoints. | ||
| - When a resource inherits another resource's connection properties, merge the parent set first to preserve overrides and annotations. | ||
| - Prefer emitting a single URI per endpoint type; if multiple endpoints exist, use a suffix that clarifies the transport (`HttpUri`, `GrpcUri`). | ||
| - Avoid recomputing expensive values in `GetConnectionProperties`; build reusable `ReferenceExpression` instances or helper methods instead. | ||
| - Expose the values as reusable properties on the resource such that users can create their own expressions when necessary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We gotta work on this next 😄