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 docs about NATS password protection #1817

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/messaging/includes/nats-explicit-username-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
When you want to explicitly provide the username and password, you can provide those as parameters. Consider the following alternative example:

```csharp
var username = builder.AddParameter("username", secret: true);
var password = builder.AddParameter("password", secret: true);

var nats = builder.AddNats("nats", userName: username, password: password);

var exampleProject = builder.AddProject<Projects.ExampleProject>()
.WithReference(nats);
```

For more information, see [External parameters](../../fundamentals/external-parameters.md).
2 changes: 2 additions & 0 deletions docs/messaging/nats-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ builder.AddProject<Projects.ExampleProject>()
// After adding all resources, run the app...
```

[!INCLUDE [nats-explicit-username-password](includes/nats-explicit-username-password.md)]

When .NET Aspire adds a container image to the app host, as shown in the preceding example with the `docker.io/library/nats` image, it creates a new NATS server instance on your local machine. A reference to your NATS server (the `nats` variable) is added to the `ExampleProject`.

The <xref:Aspire.Hosting.ResourceBuilderExtensions.WithReference%2A> method configures a connection in the `ExampleProject` named `"nats"`. For more information, see [Container resource lifecycle](../fundamentals/app-host-overview.md#container-resource-lifecycle).
Expand Down
Loading