Skip to content

Add extensibility article on how to write non-container custom resources #3850

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 18, 2025

This PR adds a new documentation article that explains how to create custom .NET Aspire resources that don't rely on containers, addressing the need for guidance on non-container extensibility patterns.

What's Added

  • New article: docs/extensibility/custom-non-container-resource.md - Comprehensive guide on creating non-container custom resources
  • Working code example: HTTP proxy resource demonstrating lifecycle hooks and dashboard integration
  • Supporting snippets: Complete, buildable code samples in docs/extensibility/snippets/HttpProxyResource/
  • Updated navigation: Added the new article to the table of contents and cross-referenced from existing articles

Key Content

The article covers:

  1. When to use non-container resources vs simpler approaches like AddConnectionString() or AddParameter()
  2. Core implementation patterns using IResource, IResourceWithEndpoints, and extension methods
  3. Lifecycle management with IDistributedApplicationLifecycleHook for startup/shutdown coordination
  4. Dashboard integration through standard .NET logging and notes on advanced notification services
  5. Practical example with an in-process HTTP proxy that demonstrates all concepts

Example Usage

var builder = DistributedApplication.CreateBuilder(args);

// Add a non-container HTTP proxy resource
var proxy = builder.AddHttpProxy("api-proxy", "https://jsonplaceholder.typicode.com");

var webapp = builder.AddProject<Projects.WebApp>("webapp")
                    .WithReference(proxy);

builder.Build().Run();

The implementation shows how to:

  • Hook into application lifecycle events
  • Manage background services and cleanup
  • Integrate with the Aspire dashboard through logging
  • Provide meaningful status updates to developers

Fixes #792.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/extensibility/custom-hosting-integration.md docs/extensibility/custom-hosting-integration
docs/extensibility/custom-non-container-resource.md docs/extensibility/custom-non-container-resource
docs/toc.yml docs/toc

Copilot AI and others added 2 commits June 18, 2025 16:45
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
…icles

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add extensiblity article on how to write a non container based custom resource Add extensibility article on how to write non-container custom resources Jun 18, 2025
@Copilot Copilot AI requested a review from IEvangelist June 18, 2025 16:47
Copilot finished work on behalf of IEvangelist June 18, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add extensiblity article on how to write a non container based custom resource
2 participants