docs-aspire
docs-aspire copied to clipboard
Add more details about the `GetEndpoint` API
Make it easier for readers to understand that the GetEndpoint API can be used to splat env vars into a dependent resource, manually. Make it clear when this is required and why you'd want to do it.
Before
var quotes = builder.AddDockerfile("quotes", "../QuoteService")
.WithHttpEndpoint(port: 8082, targetPort: 8082)
.WithExternalHttpEndpoints();
var redis = builder.AddDockerfile("redis", "../", "Dockerfile.redis")
.WithEndpoint(port: 6379, targetPort: 6379, scheme: "tcp", isExternal: true);
builder.AddProject<Projects.Web("web")
.WithEnvironment("REDIS", "localhost")
.WithEnvironment("QUOTES_ENDPOINT", "https://localhost:8082")
.WaitFor(quotes)
.WaitFor(redis);
After
var quotes = builder.AddDockerfile("quotes", "../QuoteService")
.WithHttpEndpoint(port: 8082, targetPort: 8082)
.WithExternalHttpEndpoints();
var redis = builder.AddDockerfile("redis", "../", "Dockerfile.redis")
.WithEndpoint(port: 6379, targetPort: 6379, scheme: "tcp", isExternal: true);
builder.AddProject<Projects.Web("web")
.WithEnvironment("REDIS", $"{redis.GetEndpoint("tcp").Property(EndpointProperty.Port)}")
.WithEnvironment("QUOTES_ENDPOINT", quotes.GetEndpoint("http"))
.WaitFor(quotes)
Feels like we should write a doc about how to use endpoint and reference expressions under the app host section. We have some of this content in writing a custom hosting integration. We can lift some of the content from there. It might be worth brain dumping some more ideas here so we can figure out where it goes.
cc @mitchdenny