From dcc41cb5d52a646124fbc6d2fc4c7bd29a25e4ff Mon Sep 17 00:00:00 2001 From: Mrxx99 <33566379+Mrxx99@users.noreply.github.com> Date: Sat, 12 Oct 2024 00:09:47 +0200 Subject: [PATCH] Add docs about NATS password protection --- .../includes/nats-explicit-username-password.md | 13 +++++++++++++ docs/messaging/nats-integration.md | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 docs/messaging/includes/nats-explicit-username-password.md diff --git a/docs/messaging/includes/nats-explicit-username-password.md b/docs/messaging/includes/nats-explicit-username-password.md new file mode 100644 index 0000000000..3bc16fdff5 --- /dev/null +++ b/docs/messaging/includes/nats-explicit-username-password.md @@ -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() + .WithReference(nats); +``` + +For more information, see [External parameters](../../fundamentals/external-parameters.md). diff --git a/docs/messaging/nats-integration.md b/docs/messaging/nats-integration.md index 536a16b81e..964a5e09a9 100644 --- a/docs/messaging/nats-integration.md +++ b/docs/messaging/nats-integration.md @@ -47,6 +47,8 @@ builder.AddProject() // 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 method configures a connection in the `ExampleProject` named `"nats"`. For more information, see [Container resource lifecycle](../fundamentals/app-host-overview.md#container-resource-lifecycle).