Closed andi0b closed 1 week ago
This adds an overload to resource.WithEnvironment to accept RefrerenceExpression. With this API change it's more obvious how to pass a ReferenceExpresson,
resource.WithEnvironment
RefrerenceExpression
ReferenceExpresson
This was suggested by @davidfowl in https://github.com/dotnet/aspire/issues/2111#issuecomment-2080354270
Example before this PR:
builder.AddNpmApp(...) .WithEnvironment(context => context.EnvironmentVariables["DB_CONNECTION_URL"] = db.Resource.GetConnectionUrl());
after:
builder.AddNpmApp(...) .WithEnvironment("DB_CONNECTION_URL", db.Resource.GetConnectionUrl());
In this example GetConnectionUrl() is an extension method that builds a custom connection URL and returns ReferenceExpression, see full example: https://github.com/dotnet/aspire/issues/2111#issuecomment-2080238547
GetConnectionUrl()
ReferenceExpression
@dotnet-policy-service agree
/backport to release/8.0
Started backporting to release/8.0: https://github.com/dotnet/aspire/actions/runs/8905408380
Thanks!
This adds an overload to
resource.WithEnvironment
to acceptRefrerenceExpression
. With this API change it's more obvious how to pass aReferenceExpresson
,This was suggested by @davidfowl in https://github.com/dotnet/aspire/issues/2111#issuecomment-2080354270
Example before this PR:
after:
In this example
GetConnectionUrl()
is an extension method that builds a custom connection URL and returnsReferenceExpression
, see full example: https://github.com/dotnet/aspire/issues/2111#issuecomment-2080238547Microsoft Reviewers: Open in CodeFlow