Reputation: 935
I couldn't find any extension or package for this, so I'll just show some code as an example.
In one project, I have more than 10 external APIs, if those external APIs were .NET projects in my solution, I would add them as project references in my Aspire main project.
For example this is my web project:
builder.AddProject<Projects.Main_Web>("web")
.WithReference(connectionStringHangfire)
.WithHttpsHealthCheck("/health")
.WithExternalHttpEndpoints()
.WaitForCompletion(migrations);
And for example I should have an external API for stock quotes
builder.AddExternalApi<IStock>("stock")
.WithHttpsHealthCheck("/health",r=>r.Health() ); // added one of the APIs as a health check
This way I could monitor the stock API in my resources tab, I should see what its health is, I could add the health check of the API to my health check.
I could control the base url, user, client-id, password, as parameters to my environment
I could control the log, trace an metrics of those APIs.
And finally, I could add reverse proxy around it, or vpn, around it.
Has anyone made something like this?
Upvotes: 1
Views: 400
Reputation: 33
I can not create comments yet, but if you do not find a better answer than this, or you can not wait until this is implemented in aspire as they told you in discussion in github
Consider creating a local project api that will act as a proxy for you external(s) apis, this will help for other things too (evaluate if you want this project to be publish or just for development).
In this "proxy" project you can implement strategys like retries, fallback, cache... and the endpoints for healtchecks
Upvotes: 1