Skill站外收录 @skilllib/skill-2014279396041895937
connection-properties
实现对 Aspire 资源中连接属性的统一管理与文档化,确保资源类正确提供 Host、Port、Username、Password、Uri、JdbcConnectionString 等关键连接信息,并根据资源是否托管于 Azure 包含 Azure 标识。支持父子资源间属性继承与覆盖,自动生成符合规范的 README 文档表格说明,便于依赖注入和环境变量映射。
效率工具 AI 技能
Skills.MD
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};trustServerCertificate=true`. User and password credentials are provided as separate `Username` and `Password` properties. |
### 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};trustServerCertificate=true;databaseName={DatabaseName}`. User and password credentials are provided as separate `Username` and `Password` properties. |
| `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`
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「connection-properties」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次