Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extensiblity article on how to write a non container based custom resource #792

Open
davidfowl opened this issue Apr 30, 2024 · 7 comments
Assignees
Labels

Comments

@davidfowl
Copy link
Member

As an example:

https://anthonysimmon.com/referencing-external-docker-containers-dotnet-aspire-custom-resources/

It should show how to use lifecycle hooks, the ResourceNotificationService, and the ResourceLoggerService to push updates to the dashboard.

cc @asimmon @mitchdenny

@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Apr 30, 2024
@IEvangelist IEvangelist self-assigned this Apr 30, 2024
@mitchdenny
Copy link
Member

This article should cover, or link to some kind of meta conversation around whether it makes sense to write a custom resource which is not container based.

Consider Aspire as it exists today, all of our resources are either container based, cloud-based (with or without emulators) or core resource types such as parameters.

In many cases a custom resource which is not a container could quite possibly be a very thin wrapper around AddParameter and AddConnectionString. In the article we would need to articulate the reason why someone would want to go to the extra effort to build a custom resource type.

For example, lets say you were calling an Internet hosted API that you couldn't replicate locally. That would really just be a URL and potentially some kind of API key.

@davidfowl can you give an example of a custom resource that is not:

a) something that you would NOT run locally in a container.
b) something that requires the features of dashboard updates
c) something that wouldn't be just as easily served by AddConnectionString()

@davidfowl
Copy link
Member Author

My aspire YARP resource that runs in process!:

https://github.com/davidfowl/AspireYarp

@davidfowl
Copy link
Member Author

The resource linked in the article above shows logs from the running container which makes it better than using AddConnectionString IMO.

@davidfowl
Copy link
Member Author

Another example are the Azure and AWS resources.

@asimmon
Copy link

asimmon commented May 3, 2024

If this can help, at Workleap we've been using custom resources in three ways:

  1. To host YARP (similar to, but not exactly like, https://github.com/davidfowl/AspireYarp)
  2. To host a minimal API that forwards the developer's local Azure CLI credentials to any container that uses Azure Identity with RBAC-protected resources (similar to what we distributed as a Docker image)
  3. Expose long-lived Docker containers that are managed by Docker Compose

@IEvangelist
Copy link
Member

IEvangelist commented Jun 4, 2024

@davidfowl - I like it, want me to put something together based on the YARP example or just create one that add the SmtpClient like with the MailDev example, but shows how to do so as a component?

@davidfowl
Copy link
Member Author

@IEvangelist This is low priority at the moment. We have more important stuff to document 😄. Lets let this sit for a bit.

The main thing we'd want to show here is usage of IDistribuedApplicationLifecycleHook, ResourceLoggerService and ResoruceNotificationService.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants