Skip to content

Commit 638ef54

Browse files
JamesNKIEvangelist
authored andcommitted
[9.1] Add WithExplicitStart (#2630)
* [9.1] Add WithExplicitStart * Update docs/fundamentals/app-host-overview.md
1 parent 41cede0 commit 638ef54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/fundamentals/app-host-overview.md

+19
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,25 @@ var apiservice = builder.AddProject<Projects.AspireApp_ApiService>("apiservice")
135135

136136
The preceding code adds three replicas of the "apiservice" project resource to the app model. For more information, see [.NET Aspire dashboard: Resource replicas](dashboard/explore.md#resource-replicas).
137137

138+
## Configure explicit resource start
139+
140+
Project, executable and container resources are automatically started with your distributed application by default. A resource can be configured to wait for an explicit startup instruction with the `WithExplicitStart()` method. A resource configured with `WithExplicitStart()` is initialized with `KnownResourceStates.NotStarted`.
141+
142+
```csharp
143+
var builder = DistributedApplication.CreateBuilder(args);
144+
145+
var postgres = builder.AddPostgres("postgres");
146+
var postgresdb = postgres.AddDatabase("postgresdb");
147+
148+
builder.AddProject<Projects.AspireApp_DbMigration>("dbmigration")
149+
.WithReference(postgresdb)
150+
.WithExplicitStart();
151+
```
152+
153+
In the preceeding code the "dbmigration" resource is configured to not automatically start with the distributed application.
154+
155+
Resources with explicit start can be started from the .NET Aspire dashboard by clicking the "Start" command. For more information, see [.NET Aspire dashboard: Stop or Start a resource](dashboard/explore#stop-or-start-a-resource).
156+
138157
## Reference resources
139158

140159
A reference represents a dependency between resources. For example, you can probably imagine a scenario where you a web frontend depends on a Redis cache. Consider the following example app host `Program` C# code:

0 commit comments

Comments
 (0)