dotnet / docs-aspire

This repository contains .NET Aspire documentation.
https://learn.microsoft.com/dotnet/aspire
MIT License
87 stars 113 forks source link

[New article]: Using `ExecutableResource` #1381

Open aaronpowell opened 4 months ago

aaronpowell commented 4 months ago

Proposed topic or title

Hosting an external executable

Location in table of contents.

AppHost (Orchestration)

Reason for the article

I can't find any documentation on how to use ExecutableResource or how to use the builder.AddExecutable extension to run an executable.

Article abstract

There are situations where you will need to run an external executable and treat it as a resource that other resources in the AppHost would rely on. An example of this is the Azure Static Web Apps CLI, which you would provide the frontend (say a blazor WASM project) and backend (minimal api).

It would also be important to cover how to provide command line args and how to read from WithResource calls information about the dependant resources.

Relevant searches

No response


Associated WorkItem - 308091

IEvangelist commented 4 months ago

Dude! I had no idea that this Azure SWA CLI existed...y'all need to come on the On .NET Live show and show this off to the world, especially if we can get some integrations with .NET Aspire. We should make this into an official .NET Aspire hosting package.

IEvangelist commented 4 months ago

Hey @aaronpowell - the Azure SWA CLI seems to have two installments, one using npm and the other is to just run it in Docker. I see that it's swa after installment, so it's kind of an obscure use case for an ExecutableResource no? If this was to be packaged up as an official .NET Aspire hosting resource type, think something like AzureStaticWebAppResource, it would most likely be a subclass of ContainerResource rather than an ExecuteableResource. Just thinking out loud here.

aaronpowell commented 4 months ago

I have actually already made a component for hosting it (which is how I came across this), just gotta release it 🤣.

I don't believe it has a Docker image though, it's only an executable, which gets to the root for the content request - guidance of how we can host external executables in Aspire.

IEvangelist commented 4 months ago

I love idea, and it certainly is a gap in the content right now. I'm not entirely sure on what the best practices are at this point, and still need to learn a bit about that myself. Let's try to pull on the product to see if we can't get a bit of help.

/cc @mitchdenny and @Erarndt are there any recommendations for this specific ask? We've identified a gap in the content and would like to build out some guidance for folks who are currently limited to using non-containerized exes, thus the ExecuteableResource types/APIs. With that said, how should we guide them through this?

mitchdenny commented 3 months ago

If we are going to document AddExecutable it needs to cover PublishAsDockerfile as well since AddExecutable isn't that useful when it comes to deployment.