Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Aspire 13.2 introduces convenience methods for subscribing to AppHost lifecycle events (OnBeforeStart, OnAfterResourcesCreated, OnBeforePublish, OnAfterPublish) as simpler alternatives to builder.Eventing.Subscribe<T>.

Changes

  • app-host/eventing.mdx: Updated code examples and migration guide to use new helper methods for AppHost-level events. Removed deprecated global event subscription patterns and simplified examples to focus on the recommended helper methods.
  • architecture/resource-hierarchies.mdx: Simplified endpoint access pattern to use await endpoint.GetValueAsync() instead of event subscription for accessing allocated endpoint values.

Pattern

Before:

builder.Eventing.Subscribe<BeforeStartEvent>((@event, ct) => 
{
    // Handle event
    return Task.CompletedTask;
});

After:

builder.OnBeforeStart((@event, ct) => 
{
    // Handle event
    return Task.CompletedTask;
});

For accessing allocated endpoints:

Before:

builder.Eventing.Subscribe<ResourceEndpointsAllocatedEvent>((@event, ct) =>
{
    Console.WriteLine($"Url: {endpoint.Url}");
    return Task.CompletedTask;
});

After:

var allocatedEndpoint = await endpoint.GetValueAsync();
Console.WriteLine($"Url: {allocatedEndpoint.Url}");

Resource-specific event subscriptions (e.g., builder.Eventing.Subscribe<ConnectionStringAvailableEvent>(resource, handler)) remain unchanged as they have no AppHost-level equivalents.

Original prompt

Please work on issue #315


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 29 commits January 28, 2026 10:09
* Initial plan

* Add WithBun() documentation to JavaScript integration page

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

* Update Bun example to use specific version tag

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
)

* Initial plan

* Add documentation for deployment slot support to Azure App Service

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
- Created documentation for Azure Application Insights integration.
- Created documentation for Azure Data Explorer (Kusto) integration.
- Created documentation for Azure Log Analytics integration.
- Created documentation for Azure Data Lake Storage integration.
- Added `aspire doctor` command placeholder with redirect to main CLI command page.
- Added documentation for `aspire ps` command to list running AppHost processes.
- Added documentation for `aspire stop` command to stop running AppHost processes.
…#288)

* Initial plan

* Update ASPIRE008 diagnostic page for GenerateAssemblyInfo requirement

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

* Update project file samples to modern 13.x format

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
#277)

* Add polyglot AppHost documentation for TypeScript, Python, Go, Rust, and Java

* feat: enhance PivotSelector component with marginTop prop for better layout control (#302)

docs: update Polyglot AppHost documentation with new features and usage examples

docs: add link to Polyglot AppHost in resource model documentation

docs: include Polyglot AppHost reference in get-started guide for broader language support

style: import utility classes for padding and margin in site CSS

style: create utils.css for reusable padding and margin utility classes

* fix: format project structure in polyglot AppHost documentation for clarity

---------

Co-authored-by: David Pine <david.pine@microsoft.com>
- Created a new translation guide document in MDX format to assist contributors in translating the aspire.dev documentation.
- Added two new images for the translation page link and language selector in both light and dark themes.
- Included a detailed section on supported languages, translation status, best practices, and tips for translators.
- Added FooterPreferences component for user preferences (theme, language, keyboard shortcuts).
- Introduced FooterSocials component to display social media links.
- Updated Footer.astro to include new components and adjusted layout for preferences.
- Enhanced Header.astro to remove theme and language selectors, now located in the footer.
- Implemented auto-detection of user language on first visit in Head.astro.
- Adjusted styles for new components and improved responsiveness.
- Updated translations in various languages to include "preferences".
- Changed hideOnClick prop in Head.astro from 'toggle' to true for improved clarity.
- Removed fixed width and height from .starlight-sidebar-topics-icon to allow for flexible sizing.
- Adjusted icon size in .social-icons and .starlight-sidebar-topics-icon for consistency and better responsiveness.
* Initial plan

* Add documentation for .NET tool resources

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
…ASPIREEXTENSION001 with version notes and suppression methods
Copilot AI self-assigned this Jan 29, 2026
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue #315 related to application functionality Update eventing docs for new AppHost helper methods Jan 29, 2026
Copilot AI requested a review from IEvangelist January 29, 2026 20:39
@IEvangelist
Copy link
Member

Tagging @afscrome

Copy link

@afscrome afscrome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Pedantically, the ResourceEndpointsAllocatedEvent issues are not directly related to the linked PR so could be fixed in seperate PRs (potentially targeting main rather than 9.2).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that ResourceEndpointsAllocatedEvent is deprecated, it's probably not the best first example to give of subscribing to events.

```

The preceding code is based on the starter template with the addition of the calls to the `Subscribe` API. The `Subscribe<T>` API returns a `DistributedApplicationEventSubscription` instance that you can use to unsubscribe from the event. It's common to discard the returned subscriptions, as you don't usually need to unsubscribe from events as the entire app is torn down when the AppHost is shut down.
The preceding code is based on the starter template with the addition of calls to helper methods and the `Subscribe` API. The helper methods (`OnBeforeStart`, `OnAfterResourcesCreated`, etc.) provide a convenient way to subscribe to common AppHost lifecycle events. For events that don't have a helper method, such as `ResourceEndpointsAllocatedEvent`, you can use the `Eventing.Subscribe<T>` API. The `Subscribe<T>` API returns a `DistributedApplicationEventSubscription` instance that you can use to unsubscribe from the event. It's common to discard the returned subscriptions, as you don't usually need to unsubscribe from events as the entire app is torn down when the AppHost is shut down.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For events that don't have a helper method, such as ResourceEndpointsAllocatedEvent, you can use the Eventing.Subscribe<T> API.

The only reason ResourceEndpointsAllocatedEvent doesn't have a helper is because the event is deprecated.

|--------------------------|-------------|
| `BeforeStartAsync()` | Subscribe to `BeforeStartEvent` |
| `BeforeStartAsync()` | Use `builder.OnBeforeStart(...)` or subscribe to `BeforeStartEvent` |
| `AfterEndpointsAllocatedAsync()` | Subscribe to `ResourceEndpointsAllocatedEvent` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that ResourceEndpointsAllocatedEvent is itself deprecated, this should probably recommend subscribing to the resource specific endpoint allocated event.

|--------------------------|-------------|
| `BeforeStartAsync()` | Subscribe to `BeforeStartEvent` |
| `BeforeStartAsync()` | Use `builder.OnBeforeStart(...)` or subscribe to `BeforeStartEvent` |
| `AfterEndpointsAllocatedAsync()` | Subscribe to `ResourceEndpointsAllocatedEvent` |

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that ResourceEndpointsAllocatedEvent is itself deprecated, this should probably recommend subscribing to the resource level events instead, noting that is not a drop in replacement like the other events.

// Subscribe to AfterEndpointsAllocatedEvent for resolved properties
builder.Eventing.Subscribe<AfterEndpointsAllocatedEvent>(
// Subscribe to ResourceEndpointsAllocatedEvent for resolved properties
builder.Eventing.Subscribe<ResourceEndpointsAllocatedEvent>(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ResourceEndpointsAllocatedEvent is a resource level event rather than an app wide event, so the code sample and surrounding docs probably needs more updates than this.

Probably don't even need to use the event as you can await endpoint.GetValueAsync(), rather than having to evaluate the endpoint in ResourceEndpointsAllocatedEvent.

@IEvangelist
Copy link
Member

Hey @copilot, please update this based on the comments from
afscrome who is familiar with the source code.

…y examples

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

Hey @copilot, please update this based on the comments from
afscrome who is familiar with the source code.

Updated in commit 6c81c49. I've addressed all of @afscrome's feedback:

  1. Removed ResourceEndpointsAllocatedEvent from the first example in eventing.mdx
  2. Simplified the AppHost events section to focus on the new helper methods
  3. Updated the migration guide to recommend resource-level OnResourceEndpointsAllocated(...)
  4. Simplified the resource-hierarchies.mdx example to use await endpoint.GetValueAsync() instead of event subscription

The documentation now shows the recommended patterns without the deprecated/less-preferred approaches.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/microsoft/aspire.dev/pulls/316/comments
    • Triggering command: /usr/bin/curl curl -s -H Accept: application/vnd.github.v3&#43;json REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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.

4 participants