Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/agents/connectionproperties.agent.md
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`
11 changes: 1 addition & 10 deletions .vscode/mcp.json
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"
]
}
}
}
}
29 changes: 24 additions & 5 deletions src/Aspire.Hosting.Garnet/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# Aspire.Hosting.Garnet library

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

## Install the package
## Getting started

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

In your AppHost project, install the Aspire Garnet Hosting library with [NuGet](https://www.nuget.org):

```dotnetcli
dotnet add package Aspire.Hosting.Garnet
```

## Usage example

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

```csharp
var garnet = builder.AddGarnet("cache")
var garnet = builder.AddGarnet("cache");

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

## Connection Properties

When you reference a Garnet resource using `WithReference`, the following connection properties are made available to the consuming project:

### Garnet

The Garnet resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The hostname or IP address of the Garnet server |
| `Port` | The port number the Garnet server is listening on |
| `Password` | The password for authentication (available when a password parameter is configured) |
| `Uri` | The connection URI, with the format `redis://:{Password}@{Host}:{Port}` |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation

* https://github.com/microsoft/garnet/blob/main/README.md
Expand Down
17 changes: 17 additions & 0 deletions src/Aspire.Hosting.GitHub.Models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ Then in user secrets:
}
```

## Connection Properties

When you reference a GitHub Model resource using `WithReference`, the following connection properties are made available to the consuming project:

### GitHub Model

The GitHub Model resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Uri` | The GitHub Models inference endpoint URI, with the format `https://models.github.ai/inference` |
| `Key` | The API key (PAT or GitHub App token) for authentication |
| `Model` | The model identifier for inference requests, for instance `openai/gpt-4o-mini` |
| `Organization` | The organization attributed to the request (available when configured) |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Available Models

GitHub Models supports various AI models. Some popular options include:
Expand Down
18 changes: 17 additions & 1 deletion src/Aspire.Hosting.Kafka/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,24 @@ var myService = builder.AddProject<Projects.MyService>()
.WithReference(kafka);
```

## Connection Properties

When you reference a Kafka resource using `WithReference`, the following connection properties are made available to the consuming project:

### Kafka server

The Kafka server resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The host-facing Kafka listener hostname or IP address |
| `Port` | The host-facing Kafka listener port |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation
https://learn.microsoft.com/dotnet/aspire/messaging/kafka-component

* https://learn.microsoft.com/dotnet/aspire/messaging/kafka-component

## Feedback & contributing

Expand Down
26 changes: 26 additions & 0 deletions src/Aspire.Hosting.Milvus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,33 @@ var myService = builder.AddProject<Projects.MyService>()
.WithReference(milvus);
```

## Connection Properties

When you reference a Milvus resource using `WithReference`, the following connection properties are made available to the consuming project:

### Milvus server

The Milvus server resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The hostname or IP address of the Milvus server |
| `Port` | The gRPC port exposed by the Milvus server |
| `Token` | The authentication token, with the format `root:{ApiKey}` |
| `Uri` | The gRPC endpoint URI, with the format `http://{Host}:{Port}` |

### Milvus database

The Milvus database resource combines the server properties above and adds the following connection property:

| Property Name | Description |
|---------------|-------------|
| `Database` | The Milvus database name |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation

* https://milvus.io/docs

## Feedback & contributing
Expand Down
31 changes: 30 additions & 1 deletion src/Aspire.Hosting.MongoDB/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,37 @@ var myService = builder.AddProject<Projects.MyService>()
.WithReference(db);
```

## Connection Properties

When you reference a MongoDB resource using `WithReference`, the following connection properties are made available to the consuming project:

### MongoDB server

The MongoDB server resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The hostname or IP address of the MongoDB server |
| `Port` | The port number the MongoDB server is listening on |
| `Username` | The username for authentication |
| `Password` | The password for authentication (available when a password parameter is configured) |
| `AuthenticationDatabase` | The authentication database (available when a password parameter is configured) |
| `AuthenticationMechanism` | The authentication mechanism (available when a password parameter is configured) |
| `Uri` | The connection URI, with the format `mongodb://{Username}:{Password}@{Host}:{Port}/?authSource={AuthenticationDatabase}&authMechanism={AuthenticationMechanism}` |

### MongoDB database

The MongoDB database resource combines the server properties above and adds the following connection property:

| Property Name | Description |
|---------------|-------------|
| `Database` | The MongoDB database name |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation
https://learn.microsoft.com/dotnet/aspire/database/mongodb-component

* https://learn.microsoft.com/dotnet/aspire/database/mongodb-component

## Feedback & contributing

Expand Down
32 changes: 31 additions & 1 deletion src/Aspire.Hosting.MySql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,38 @@ var myService = builder.AddProject<Projects.MyService>()
.WithReference(db);
```

## Connection Properties

When you reference a MySQL resource using `WithReference`, the following connection properties are made available to the consuming project:

### MySQL server

The MySQL server resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The hostname or IP address of the MySQL server |
| `Port` | The port number the MySQL server is listening on |
| `Username` | The username for authentication |
| `Password` | The password for authentication |
| `Uri` | The connection URI, with the format `mysql://root:{Password}@{Host}:{Port}` |
| `JdbcConnectionString` | The JDBC connection string for MySQL, with the format `jdbc:mysql://{Host}:{Port}/?user={Username}&password={Password}` |

### MySQL database

The MySQL database resource combines the server properties above and adds the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Database` | The MySQL database name |
| `Uri` | The database-specific URI, with the format `mysql://root:{Password}@{Host}:{Port}/{Database}` |
| `JdbcConnectionString` | The database-specific JDBC connection string, with the format `jdbc:mysql://{Host}:{Port}/{Database}?user={Username}&password={Password}` |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation
https://learn.microsoft.com/dotnet/aspire/database/mysql-component

* https://learn.microsoft.com/dotnet/aspire/database/mysql-component

## Feedback & contributing

Expand Down
21 changes: 20 additions & 1 deletion src/Aspire.Hosting.Nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,27 @@ var myService = builder.AddProject<Projects.MyService>()
.WithReference(nats);
```

## Connection Properties

When you reference a NATS resource using `WithReference`, the following connection properties are made available to the consuming project:

### NATS server

The NATS server resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Host` | The hostname or IP address of the NATS server |
| `Port` | The port number the NATS server is listening on |
| `Username` | The username for authentication |
| `Password` | The password for authentication |
| `Uri` | The connection URI with the format `nats://{Username}:{Password}@{Host}:{Port}` |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation
https://learn.microsoft.com/dotnet/aspire/messaging/nats-component

* https://learn.microsoft.com/dotnet/aspire/messaging/nats-component

## Feedback & contributing

Expand Down
24 changes: 24 additions & 0 deletions src/Aspire.Hosting.OpenAI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ var chat = openai.AddModel("chat", "gpt-4o-mini");

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

## Connection Properties

When you reference an OpenAI resource using `WithReference`, the following connection properties are made available to the consuming project:

### OpenAIResource

The OpenAI resource exposes the following connection properties:

| Property Name | Description |
|---------------|-------------|
| `Endpoint` | The base endpoint URI for the OpenAI API, with the format `https://api.openai.com/v1` |
| `Uri` | The endpoint URI (same as Endpoint), with the format `https://api.openai.com/v1` |
| `Key` | The API key for authentication |

### OpenAI model

The OpenAI model resource combines the parent properties above and adds the following connection property:

| Property Name | Description |
|---------------|-------------|
| `Model` | The model identifier for inference requests, for instance `gpt-4o-mini` |

Aspire exposes each property as an environment variable named `[RESOURCE]_[PROPERTY]`. For instance, the `Uri` property of a resource called `db1` becomes `DB1_URI`.

## Additional documentation

* https://platform.openai.com/docs/models
Expand Down
10 changes: 10 additions & 0 deletions src/Aspire.Hosting.Oracle/OracleDatabaseResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ public class OracleDatabaseResource(string name, string databaseName, OracleData
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"{Parent}/{DatabaseName}");

/// <summary>
/// Gets the connection URI expression for the Oracle database.
/// </summary>
/// <remarks>
/// Format: <c>oracle://{user}:{password}@{host}:{port}/{database}</c>.
/// </remarks>
public ReferenceExpression UriExpression =>
ReferenceExpression.Create($"{Parent.UriExpression}/{DatabaseName:uri}");

/// <summary>
/// Gets the JDBC connection string for the Oracle Database.
/// </summary>
Expand All @@ -48,6 +57,7 @@ private static string ThrowIfNullOrEmpty([NotNull] string? argument, [CallerArgu
IEnumerable<KeyValuePair<string, ReferenceExpression>> IResourceWithConnectionString.GetConnectionProperties() =>
Parent.CombineProperties([
new("Database", ReferenceExpression.Create($"{DatabaseName}")),
new("Uri", UriExpression),
new("JdbcConnectionString", JdbcConnectionString),
]);
}
Loading