Create `IConfiguration` extension methods to get Aspire convention-based values
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
It would be really nice if Aspire added some extension methods on `IConfiguration` that allow for convenience-based APIs for getting values.
For example, it's ugly to ask the config for `"services__serviceName__0"`. Something like this might be really useful:
```csharp
public static class ConfigurationExtensions
{
public static Uri GetServiceHttpUri(this IConfiguration config, string name) =>
config.GetServiceUri(name, 0);
public static Uri GetServiceHttpsUri(this IConfiguration config, string name) =>
config.GetServiceUri(name, 1);
private static Uri GetServiceUri(this IConfiguration config, string name, int index)
{
ArgumentException.ThrowIfNull(name);
var url = config[$"services:{name}:{index}"];
return new(url);
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.