You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/app-host/configuration.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,8 @@ By default, the dashboard is automatically started by the app host. The dashboar
77
77
|`ASPIRE_DASHBOARD_OTLP_HTTP_ENDPOINT_URL`|`null`| Configures the dashboard OTLP HTTP address. Used by the dashboard to receive telemetry over OTLP. If only `ASPIRE_DASHBOARD_OTLP_HTTP_ENDPOINT_URL` is configured then it is set on resources as the `OTEL_EXPORTER_OTLP_ENDPOINT` env var. The `OTEL_EXPORTER_OTLP_PROTOCOL` env var is `http/protobuf`. |
78
78
|`ASPIRE_DASHBOARD_CORS_ALLOWED_ORIGINS`|`null`| Overrides the CORS allowed origins configured in the dashboard. This setting replaces the default behavior of calculating allowed origins based on resource endpoints. |
79
79
|`ASPIRE_DASHBOARD_FRONTEND_BROWSERTOKEN`| Automatically generated 128-bit entropy token. | Configures the frontend browser token. This is the value that must be entered to access the dashboard when the auth mode is BrowserToken. If no browser token is specified then a new token is generated each time the app host is launched. |
80
+
|`ASPIRE_DASHBOARD_TELEMETRY_OPTOUT`|`false`| Configures the dashboard to never send [usage telemetry](../fundamentals/dashboard/microsoft-collected-dashboard-telemetry.md). |
81
+
|`ASPIRE_DASHBOARD_AI_DISABLED`|`false`|[GitHub Copilot in the dashboard](../fundamentals/dashboard/copilot.md) is available when the app host is launched by a supported IDE. When set to `true` Copilot is disabled in the dashboard and no Copilot UI is visible. |
Copy file name to clipboardExpand all lines: docs/app-host/eventing.md
+10-28Lines changed: 10 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -26,20 +26,21 @@ All of the preceding events are analogous to the [app host life cycles](xref:dot
26
26
27
27
To subscribe to the built-in app host events, use the eventing API. After you have a distributed application builder instance, walk up to the <xref:Aspire.Hosting.IDistributedApplicationBuilder.Eventing?displayProperty=nameWithType> property and call the <xref:Aspire.Hosting.Eventing.IDistributedApplicationEventing.Subscribe``1(System.Func{``0,System.Threading.CancellationToken,System.Threading.Tasks.Task})> API. Consider the following sample app host _Program.cs_ file:
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 <xref:Aspire.Hosting.Eventing.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 app host is shut down.
32
32
33
33
When the app host is run, by the time the .NET Aspire dashboard is displayed, you should see the following log output in the console:
The log output confirms that event handlers are executed in the order of the app host life cycle events. The subscription order doesn't affect execution order. The `BeforeStartEvent` is triggered first, followed by `AfterEndpointsAllocatedEvent`, and finally `AfterResourcesCreatedEvent`.
37
+
The log output confirms that event handlers are executed in the order of the app host life cycle events. The subscription order doesn't affect execution order. The `BeforeStartEvent` is triggered first, followed by `AfterEndpointsAllocatedEvent`, then each resource has its `ResourceEndpointsAllocatedEvent` event fired, and finally `AfterResourcesCreatedEvent`.
38
38
39
39
## Resource eventing
40
40
41
41
In addition to the app host events, you can also subscribe to resource events. Resource events are raised specific to an individual resource. Resource events are defined as implementations of the <xref:Aspire.Hosting.Eventing.IDistributedApplicationResourceEvent> interface. The following resource events are available in the listed order:
42
42
43
+
1.`InitializeResourceEvent`: Raised by orchestrators to signal to resources that they should initialize themselves.
43
44
1.<xref:Aspire.Hosting.ApplicationModel.ConnectionStringAvailableEvent>: Raised when a connection string becomes available for a resource.
44
45
1.<xref:Aspire.Hosting.ApplicationModel.BeforeResourceStartedEvent>: Raised before the orchestrator starts a new resource.
45
46
1.<xref:Aspire.Hosting.ApplicationModel.ResourceReadyEvent>: Raised when a resource initially transitions to a ready state.
@@ -48,13 +49,13 @@ In addition to the app host events, you can also subscribe to resource events. R
48
49
49
50
To subscribe to resource events, use the eventing API. After you have a distributed application builder instance, walk up to the <xref:Aspire.Hosting.IDistributedApplicationBuilder.Eventing?displayProperty=nameWithType> property and call the <xref:Aspire.Hosting.Eventing.IDistributedApplicationEventing.Subscribe``1(Aspire.Hosting.ApplicationModel.IResource,System.Func{``0,System.Threading.CancellationToken,System.Threading.Tasks.Task})> API. Consider the following sample app host _Program.cs_ file:
The preceding code subscribes to the `ResourceReadyEvent`, `ConnectionStringAvailableEvent`, and `BeforeResourceStartedEvent` events on the `cache` resource. When <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis*> is called, it returns an <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1> where `T` is a <xref:Aspire.Hosting.ApplicationModel.RedisResource>. The resource builder exposes the resource as the <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1.Resource?displayProperty=nameWithType> property. The resource in question is then passed to the `Subscribe` API to subscribe to the events on the resource.
54
+
The preceding code subscribes to the `InitializeResourceEvent`, `ResourceReadyEvent`, `ConnectionStringAvailableEvent`, and `BeforeResourceStartedEvent` events on the `cache` resource. When <xref:Aspire.Hosting.RedisBuilderExtensions.AddRedis*> is called, it returns an <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1> where `T` is a <xref:Aspire.Hosting.ApplicationModel.RedisResource>. The resource builder exposes the resource as the <xref:Aspire.Hosting.ApplicationModel.IResourceBuilder`1.Resource?displayProperty=nameWithType> property. The resource in question is then passed to the `Subscribe` API to subscribe to the events on the resource.
54
55
55
56
When the app host is run, by the time the .NET Aspire dashboard is displayed, you should see the following log output in the console:
> Some events are blocking. For example, when the `BeforeResourceStartEvent` is published, the startup of the resource will be blocked until all subscriptions for that event on a given resource have completed executing. Whether an event is blocking or not depends on how it is published (see the following section).
@@ -105,28 +106,9 @@ The preceding code:
105
106
106
107
When this app host is run, the life cycle hook is executed for each event. The following output is generated:
107
108
108
-
```Output
109
-
info: LifecycleLogger[0]
110
-
BeforeStartAsync
111
-
info: Aspire.Hosting.DistributedApplication[0]
112
-
Aspire version: 9.0.0
113
-
info: Aspire.Hosting.DistributedApplication[0]
114
-
Distributed application starting.
115
-
info: Aspire.Hosting.DistributedApplication[0]
116
-
Application host directory is: ..\AspireApp\AspireApp.AppHost
117
-
info: LifecycleLogger[0]
118
-
AfterEndpointsAllocatedAsync
119
-
info: Aspire.Hosting.DistributedApplication[0]
120
-
Now listening on: https://localhost:17043
121
-
info: Aspire.Hosting.DistributedApplication[0]
122
-
Login to the dashboard at https://localhost:17043/login?t=d80f598bc8a64c7ee97328a1cbd55d72
123
-
info: LifecycleLogger[0]
124
-
AfterResourcesCreatedAsync
125
-
info: Aspire.Hosting.DistributedApplication[0]
126
-
Distributed application started. Press Ctrl+C to shut down.
127
-
```
128
-
129
-
The preferred way to hook into the app host life cycle is to use the eventing API. For more information, see [Eventing in .NET Aspire](#eventing-in-net-aspire).
0 commit comments