docs-aspire icon indicating copy to clipboard operation
docs-aspire copied to clipboard

Add more details about the `GetEndpoint` API

Open IEvangelist opened this issue 1 year ago • 1 comments

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)
       

IEvangelist avatar Dec 04 '24 21:12 IEvangelist

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

davidfowl avatar Dec 05 '24 08:12 davidfowl