Skip to content

Commit c2cb88e

Browse files
committed
Update connection properties for non-Azure resources
1 parent 5886086 commit c2cb88e

File tree

23 files changed

+520
-33
lines changed

23 files changed

+520
-33
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
name: connection-properties-expert
3+
description: Specialized agent for creating and improving Connection Properties in Aspire resource and README files.
4+
tools: ['read', 'search', 'edit']
5+
---
6+
7+
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.
8+
9+
## IResourceWithConnectionString.GetConnectionProperties rules
10+
11+
Common Connection properties are
12+
- Host
13+
- Port
14+
- Password, when available
15+
- UserName, when available
16+
- Uri, representing a service resource url, like [protocol]://[username]:[password]@[host]:[port]/[subresource]?parameter=...
17+
- 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.
18+
- DatabaseName
19+
- JdbcConnectionString, a JDBC connection string format for the specific resource (search online Azure SDK documentation for reference formats).
20+
21+
If a `JdbcConnectionString` property doesn't exist and there is online documentation about connecting to this resource using JDBC, create it.
22+
23+
## Parent resources
24+
25+
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.
26+
27+
To inherit parent properties use the `ConnectionPropertiesExtensions.CombineProperties` method like this:
28+
29+
```c#
30+
IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() =>
31+
Parent.CombineProperties([
32+
new("Database", ReferenceExpression.Create($"{DatabaseName}")),
33+
new("Uri", UriExpression),
34+
new("JdbcConnectionString", JdbcConnectionString),
35+
]);
36+
```
37+
38+
Where `Parent` comes from the `IResourceWithParent` interface.
39+
40+
## Documentation
41+
42+
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`.
43+
44+
Here is a sample section for Sql Server:
45+
46+
```md
47+
## Connection Properties
48+
49+
When you reference a SQL Server resource using `WithReference`, the following connection properties are made available to the consuming project:
50+
51+
### SQL Server server
52+
53+
The SQL Server server resource exposes the following connection properties:
54+
55+
| Property Name | Description |
56+
|---------------|-------------|
57+
| `Host` | The hostname or IP address of the SQL Server |
58+
| `Port` | The port number the SQL Server is listening on |
59+
| `Username` | The username for authentication |
60+
| `Password` | The password for authentication |
61+
| `Uri` | The connection URI in mssql:// format, with the format `mssql://{Username}:{Password}@{Host}:{Port}` |
62+
| `JdbcConnectionString` | JDBC-format connection string, with the format `jdbc:sqlserver://{Host}:{Port};user={Username};password={Password};trustServerCertificate=true` |
63+
64+
### SQL Server database
65+
66+
The SQL Server database resource inherits all properties from its parent `SqlServerServerResource` and adds:
67+
68+
| Property Name | Description |
69+
|---------------|-------------|
70+
| `Uri` | The connection URI in mssql:// format, with the format `mssql://{Username}:{Password}@{Host}:{Port}/{DatabaseName}` |
71+
| `JdbcConnectionString` | JDBC connection string with database name, with the format `jdbc:sqlserver://{Host}:{Port};user={Username};password={Password};trustServerCertificate=true;databaseName={DatabaseName}` |
72+
| `Database` | The name of the database |
73+
74+
These properties are automatically injected into your application's environment variables or available to create custom values.
75+
```
76+
77+
- The table should be formatted identically to this sample
78+
- Each resource gets its own table
79+
- Uri and JdbcConnectionString must have their format in the description
80+
- The `Connection Properties` should be the last before external links like `Additional documentation`

.vscode/mcp.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
{
22
"servers": {
3-
"aspire-mcp-tools": {
4-
"type": "stdio",
5-
"command": "dotnet",
6-
"args": [
7-
"run",
8-
"--project",
9-
"${workspaceFolder}/tools/AspireMcpTools/AspireMcpTools.csproj"
10-
]
11-
}
123
}
13-
}
4+
}

src/Aspire.Hosting.Garnet/README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# Aspire.Hosting.Garnet library
22

3-
Provides extension methods and resource definitions for an Aspire AppHost to configure Cache for Garnet.
3+
Provides extension methods and resource definitions for an Aspire AppHost to configure a Garnet cache resource.
44

5-
## Install the package
5+
## Getting started
66

7-
In your AppHost project, install the `Aspire.Hosting.Garnet` library with [NuGet](https://www.nuget.org):
7+
### Install the package
8+
9+
In your AppHost project, install the Aspire Garnet Hosting library with [NuGet](https://www.nuget.org):
810

911
```dotnetcli
1012
dotnet add package Aspire.Hosting.Garnet
1113
```
1214

1315
## Usage example
1416

15-
Then, in the _AppHost.cs_ file of `AppHost`, register a Garnet server and consume the connection using the following methods:
17+
Then, in the _AppHost.cs_ file of `AppHost`, add a Garnet resource and consume the connection using the following methods:
1618

1719
```csharp
18-
var garnet = builder.AddGarnet("cache")
20+
var garnet = builder.AddGarnet("cache");
1921

2022
var myService = builder.AddProject<Projects.MyService>()
2123
.WithReference(garnet);
@@ -27,6 +29,23 @@ The `WithReference` method configures a connection in the `MyService` project na
2729
builder.AddRedisClient("cache");
2830
```
2931

32+
## Connection Properties
33+
34+
When you reference a Garnet resource using `WithReference`, the following connection properties are made available to the consuming project:
35+
36+
### Garnet
37+
38+
The Garnet resource exposes the following connection properties:
39+
40+
| Property Name | Description |
41+
|---------------|-------------|
42+
| `Host` | The hostname or IP address of the Garnet server |
43+
| `Port` | The port number the Garnet server is listening on |
44+
| `Password` | The password for authentication (available when a password parameter is configured) |
45+
| `Uri` | The connection URI, with the format `redis://:{Password}@{Host}:{Port}` |
46+
47+
These properties are automatically injected into your application's environment variables or available to create custom values.
48+
3049
## Additional documentation
3150

3251
* https://github.com/microsoft/garnet/blob/main/README.md

src/Aspire.Hosting.GitHub.Models/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ Then in user secrets:
7878
}
7979
```
8080

81+
## Connection Properties
82+
83+
When you reference a GitHub Model resource using `WithReference`, the following connection properties are made available to the consuming project:
84+
85+
### GitHub Model
86+
87+
The GitHub Model resource exposes the following connection properties:
88+
89+
| Property Name | Description |
90+
|---------------|-------------|---------------|
91+
| `Uri` | The GitHub Models inference endpoint URI, with the format `https://models.github.ai/inference` |
92+
| `Key` | The API key (PAT or GitHub App token) for authentication |
93+
| `Model` | The model identifier for inference requests, for instance `openai/gpt-4o-mini` |
94+
| `Organization` | The organization attributed to the request (available when configured) |
95+
96+
These properties are automatically injected into your application's environment variables or available to create custom values.
97+
8198
## Available Models
8299

83100
GitHub Models supports various AI models. Some popular options include:

src/Aspire.Hosting.Kafka/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,24 @@ var myService = builder.AddProject<Projects.MyService>()
2323
.WithReference(kafka);
2424
```
2525

26+
## Connection Properties
27+
28+
When you reference a Kafka resource using `WithReference`, the following connection properties are made available to the consuming project:
29+
30+
### Kafka server
31+
32+
The Kafka server resource exposes the following connection properties:
33+
34+
| Property Name | Description |
35+
|---------------|-------------|
36+
| `Host` | The host-facing Kafka listener hostname or IP address |
37+
| `Port` | The host-facing Kafka listener port |
38+
39+
These properties are automatically injected into your application's environment variables or available to create custom values.
40+
2641
## Additional documentation
27-
https://learn.microsoft.com/dotnet/aspire/messaging/kafka-component
42+
43+
* https://learn.microsoft.com/dotnet/aspire/messaging/kafka-component
2844

2945
## Feedback & contributing
3046

src/Aspire.Hosting.Milvus/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,33 @@ var myService = builder.AddProject<Projects.MyService>()
2323
.WithReference(milvus);
2424
```
2525

26+
## Connection Properties
27+
28+
When you reference a Milvus resource using `WithReference`, the following connection properties are made available to the consuming project:
29+
30+
### Milvus server
31+
32+
The Milvus server resource exposes the following connection properties:
33+
34+
| Property Name | Description |
35+
|---------------|-------------|
36+
| `Host` | The hostname or IP address of the Milvus server |
37+
| `Port` | The gRPC port exposed by the Milvus server |
38+
| `Token` | The authentication token, with the format `root:{ApiKey}` |
39+
| `Uri` | The gRPC endpoint URI, with the format `http://{Host}:{Port}` |
40+
41+
### Milvus database
42+
43+
The Milvus database resource combines the server properties above and adds the following connection property:
44+
45+
| Property Name | Description |
46+
|---------------|-------------|
47+
| `Database` | The Milvus database name |
48+
49+
These properties are automatically injected into your application's environment variables or available to create custom values.
50+
2651
## Additional documentation
52+
2753
* https://milvus.io/docs
2854

2955
## Feedback & contributing

src/Aspire.Hosting.MongoDB/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,37 @@ var myService = builder.AddProject<Projects.MyService>()
2323
.WithReference(db);
2424
```
2525

26+
## Connection Properties
27+
28+
When you reference a MongoDB resource using `WithReference`, the following connection properties are made available to the consuming project:
29+
30+
### MongoDB server
31+
32+
The MongoDB server resource exposes the following connection properties:
33+
34+
| Property Name | Description |
35+
|---------------|-------------|
36+
| `Host` | The hostname or IP address of the MongoDB server |
37+
| `Port` | The port number the MongoDB server is listening on |
38+
| `Username` | The username for authentication |
39+
| `Password` | The password for authentication (available when a password parameter is configured) |
40+
| `AuthenticationDatabase` | The authentication database (available when a password parameter is configured) |
41+
| `AuthenticationMechanism` | The authentication mechanism (available when a password parameter is configured) |
42+
| `Uri` | The connection URI, with the format `mongodb://{Username}:{Password}@{Host}:{Port}/?authSource={AuthenticationDatabase}&authMechanism={AuthenticationMechanism}` |
43+
44+
### MongoDB database
45+
46+
The MongoDB database resource combines the server properties above and adds the following connection property:
47+
48+
| Property Name | Description |
49+
|---------------|-------------|
50+
| `Database` | The MongoDB database name |
51+
52+
These properties are automatically injected into your application's environment variables or available to create custom values.
53+
2654
## Additional documentation
27-
https://learn.microsoft.com/dotnet/aspire/database/mongodb-component
55+
56+
* https://learn.microsoft.com/dotnet/aspire/database/mongodb-component
2857

2958
## Feedback & contributing
3059

src/Aspire.Hosting.MySql/README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,38 @@ var myService = builder.AddProject<Projects.MyService>()
2323
.WithReference(db);
2424
```
2525

26+
## Connection Properties
27+
28+
When you reference a MySQL resource using `WithReference`, the following connection properties are made available to the consuming project:
29+
30+
### MySQL server
31+
32+
The MySQL server resource exposes the following connection properties:
33+
34+
| Property Name | Description |
35+
|---------------|-------------|---------------|
36+
| `Host` | The hostname or IP address of the MySQL server |
37+
| `Port` | The port number the MySQL server is listening on |
38+
| `Username` | The username for authentication |
39+
| `Password` | The password for authentication |
40+
| `Uri` | The connection URI, with the format `mysql://root:{Password}@{Host}:{Port}` |
41+
| `JdbcConnectionString` | The JDBC connection string for MySQL, with the format `jdbc:mysql://{Host}:{Port}/?user={Username}&password={Password}` |
42+
43+
### MySQL database
44+
45+
The MySQL database resource combines the server properties above and adds the following connection properties:
46+
47+
| Property Name | Description |
48+
|---------------|-------------|
49+
| `Database` | The MySQL database name |
50+
| `Uri` | The database-specific URI, with the format `mysql://root:{Password}@{Host}:{Port}/{Database}` |
51+
| `JdbcConnectionString` | The database-specific JDBC connection string, with the format `jdbc:mysql://{Host}:{Port}/{Database}?user={Username}&password={Password}` |
52+
53+
These properties are automatically injected into your application's environment variables or available to create custom values.
54+
2655
## Additional documentation
27-
https://learn.microsoft.com/dotnet/aspire/database/mysql-component
56+
57+
* https://learn.microsoft.com/dotnet/aspire/database/mysql-component
2858

2959
## Feedback & contributing
3060

src/Aspire.Hosting.Nats/README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,27 @@ var myService = builder.AddProject<Projects.MyService>()
2323
.WithReference(nats);
2424
```
2525

26+
## Connection Properties
27+
28+
When you reference a NATS resource using `WithReference`, the following connection properties are made available to the consuming project:
29+
30+
### NATS server
31+
32+
The NATS server resource exposes the following connection properties:
33+
34+
| Property Name | Description |
35+
|---------------|-------------|
36+
| `Host` | The hostname or IP address of the NATS server |
37+
| `Port` | The port number the NATS server is listening on |
38+
| `Username` | The username for authentication |
39+
| `Password` | The password for authentication |
40+
| `Uri` | The connection URI with the format `nats://{Username}:{Password}@{Host}:{Port}` |
41+
42+
These properties are automatically injected into your application's environment variables or available to create custom values.
43+
2644
## Additional documentation
27-
https://learn.microsoft.com/dotnet/aspire/messaging/nats-component
45+
46+
* https://learn.microsoft.com/dotnet/aspire/messaging/nats-component
2847

2948
## Feedback & contributing
3049

src/Aspire.Hosting.OpenAI/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,30 @@ var chat = openai.AddModel("chat", "gpt-4o-mini");
118118

119119
Both the parent and model connection strings will include the custom endpoint.
120120

121+
## Connection Properties
122+
123+
When you reference an OpenAI resource using `WithReference`, the following connection properties are made available to the consuming project:
124+
125+
### OpenAIResource
126+
127+
The OpenAI resource exposes the following connection properties:
128+
129+
| Property Name | Description |
130+
|---------------|-------------|
131+
| `Endpoint` | The base endpoint URI for the OpenAI API, with the format `https://api.openai.com/v1` |
132+
| `Uri` | The endpoint URI (same as Endpoint), with the format `https://api.openai.com/v1` |
133+
| `Key` | The API key for authentication |
134+
135+
### OpenAI model
136+
137+
The OpenAI model resource combines the parent properties above and adds the following connection property:
138+
139+
| Property Name | Description |
140+
|---------------|-------------|
141+
| `Model` | The model identifier for inference requests, for instance `gpt-4o-mini` |
142+
143+
These properties are automatically injected into your application's environment variables or available to create custom values.
144+
121145
## Additional documentation
122146

123147
* https://platform.openai.com/docs/models

0 commit comments

Comments
 (0)