-
Notifications
You must be signed in to change notification settings - Fork 850
Update connection properties for non-Azure resources #12583
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
6 commits
Select commit
Hold shift + click to select a range
f501a23
Update connection properties for non-Azure resources
sebastienros d37f8c6
Improve env doc in readmes
sebastienros c1da999
Copilot review
sebastienros 0d8df64
Fix tests
sebastienros 994ea73
Fix tests
sebastienros 781017a
Fix test
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,80 @@ | ||
| --- | ||
| name: connection-properties-expert | ||
| description: Specialized agent for creating and improving Connection Properties in Aspire resource and README files. | ||
| tools: ['read', 'search', 'edit'] | ||
| --- | ||
|
|
||
| You are a C# developer. Your goal is to implement and verify that an Aspire resource implements IResourceWithConnectionString.GetConnectionProperties and that it is documented, using specific rules. | ||
|
|
||
| ## IResourceWithConnectionString.GetConnectionProperties rules | ||
|
|
||
| Common Connection properties are | ||
| - Host | ||
| - Port | ||
| - Password, when available | ||
| - UserName, when available | ||
| - Uri, representing a service resource url, like [protocol]://[username]:[password]@[host]:[port]/[subresource]?parameter=... | ||
| - Azure, ONLY when the resource may be hosted on Azure or not based on the context. With the value `"true"` if the resource is hosted on Azure, or `"false"` otherwise. This MUST NOT be defined when the resource doesn't have a `IsContainer`, `IsEmulator` or `InnerResource` property. | ||
| - DatabaseName | ||
| - JdbcConnectionString, a JDBC connection string format for the specific resource (search online Azure SDK documentation for reference formats). | ||
|
|
||
| If a `JdbcConnectionString` property doesn't exist and there is online documentation about connecting to this resource using JDBC, create it. | ||
|
|
||
| ## Parent resources | ||
|
|
||
| When a resource class implement IResourceWithParent its connection properties should inherit its parent's ones. Then define it own to override the values, like Uri if applicable. | ||
|
|
||
| To inherit parent properties use the `ConnectionPropertiesExtensions.CombineProperties` method like this: | ||
|
|
||
| ```c# | ||
| IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() => | ||
| Parent.CombineProperties([ | ||
| new("Database", ReferenceExpression.Create($"{DatabaseName}")), | ||
| new("Uri", UriExpression), | ||
| new("JdbcConnectionString", JdbcConnectionString), | ||
| ]); | ||
| ``` | ||
|
|
||
| Where `Parent` comes from the `IResourceWithParent` interface. | ||
|
|
||
| ## Documentation | ||
|
|
||
| Each Azure resource has an associated README.md file in the same folder. Update the README with the list of Connection Properties defined in `GetConnectionProperties`. | ||
|
|
||
| Here is a sample section for Sql Server: | ||
|
|
||
| ```md | ||
| ## Connection Properties | ||
|
|
||
| When you reference a SQL Server resource using `WithReference`, the following connection properties are made available to the consuming project: | ||
|
|
||
| ### SQL Server server | ||
|
|
||
| The SQL Server server resource exposes the following connection properties: | ||
|
|
||
| | Property Name | Description | | ||
| |---------------|-------------| | ||
| | `Host` | The hostname or IP address of the SQL Server | | ||
| | `Port` | The port number the SQL Server is listening on | | ||
| | `Username` | The username for authentication | | ||
| | `Password` | The password for authentication | | ||
| | `Uri` | The connection URI in mssql:// format, with the format `mssql://{Username}:{Password}@{Host}:{Port}` | | ||
| | `JdbcConnectionString` | JDBC-format connection string, with the format `jdbc:sqlserver://{Host}:{Port};user={Username};password={Password};trustServerCertificate=true` | | ||
|
|
||
| ### SQL Server database | ||
|
|
||
| The SQL Server database resource inherits all properties from its parent `SqlServerServerResource` and adds: | ||
|
|
||
| | Property Name | Description | | ||
| |---------------|-------------| | ||
| | `Uri` | The connection URI in mssql:// format, with the format `mssql://{Username}:{Password}@{Host}:{Port}/{DatabaseName}` | | ||
| | `JdbcConnectionString` | JDBC connection string with database name, with the format `jdbc:sqlserver://{Host}:{Port};user={Username};password={Password};trustServerCertificate=true;databaseName={DatabaseName}` | | ||
| | `Database` | The name of the database | | ||
|
|
||
| Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`. | ||
| ``` | ||
|
|
||
| - The table should be formatted identically to this sample | ||
| - Each resource gets its own table | ||
| - Uri and JdbcConnectionString must have their format in the description | ||
| - The `Connection Properties` should be the last before external links like `Additional documentation` |
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 |
|---|---|---|
| @@ -1,13 +1,4 @@ | ||
| { | ||
| "servers": { | ||
| "aspire-mcp-tools": { | ||
| "type": "stdio", | ||
| "command": "dotnet", | ||
| "args": [ | ||
| "run", | ||
| "--project", | ||
| "${workspaceFolder}/tools/AspireMcpTools/AspireMcpTools.csproj" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.