Skip to content
Docs Try Aspire

NatsBuilderExtensions Methods

Class Methods 6 members
Provides extension methods for adding NATS resources to the application model.
AddNats(IDistributedApplicationBuilder, string, int?) Section titled AddNats(IDistributedApplicationBuilder, string, int?) extension IResourceBuilder<NatsServerResource>
Adds a NATS server resource to the application model. A container is used for local development. This configures a default user name and password for the NATS server.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> AddNats(
this IDistributedApplicationBuilder builder,
string name,
int? port)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
port int? The host port for NATS server.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.
AddNats(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) Section titled AddNats(IDistributedApplicationBuilder, string, int?, IResourceBuilder<ParameterResource>, IResourceBuilder<ParameterResource>) extension IResourceBuilder<NatsServerResource>
Adds a NATS server resource to the application model. A container is used for local development.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> AddNats(
this IDistributedApplicationBuilder builder,
string name,
int? port = null,
IResourceBuilder<ParameterResource>? userName = null,
IResourceBuilder<ParameterResource>? password = null)
{
// ...
}
}
builder IDistributedApplicationBuilder The Hosting.IDistributedApplicationBuilder.
name string The name of the resource. This name will be used as the connection string name when referenced in a dependency.
port int? optional The host port for NATS server.
userName IResourceBuilder<ParameterResource> optional The parameter used to provide the user name for the PostgreSQL resource. If null a default value will be used.
password IResourceBuilder<ParameterResource> optional The parameter used to provide the administrator password for the PostgreSQL resource. If null a random password will be generated.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the container image.
WithDataBindMount(IResourceBuilder<NatsServerResource>, string, bool) Section titled WithDataBindMount(IResourceBuilder<NatsServerResource>, string, bool) extension IResourceBuilder<NatsServerResource>
Adds a bind mount for the data folder to a NATS container resource.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> WithDataBindMount(
this IResourceBuilder<NatsServerResource> builder,
string source,
bool isReadOnly = false)
{
// ...
}
}
builder IResourceBuilder<NatsServerResource> The resource builder.
source string The source directory on the host to mount into the container.
isReadOnly bool optional A flag that indicates if this is a read-only mount.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.
WithDataVolume(IResourceBuilder<NatsServerResource>, string?, bool) Section titled WithDataVolume(IResourceBuilder<NatsServerResource>, string?, bool) extension IResourceBuilder<NatsServerResource>
Adds a named volume for the data folder to a NATS container resource.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> WithDataVolume(
this IResourceBuilder<NatsServerResource> builder,
string? name = null,
bool isReadOnly = false)
{
// ...
}
}
builder IResourceBuilder<NatsServerResource> The resource builder.
name string? optional The name of the volume. Defaults to an auto-generated name based on the application and resource names.
isReadOnly bool optional A flag that indicates if this is a read-only volume.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.
WithJetStream(IResourceBuilder<NatsServerResource>, string?) Section titled WithJetStream(IResourceBuilder<NatsServerResource>, string?) extension IResourceBuilder<NatsServerResource>
Adds JetStream support to the NATS server resource.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> WithJetStream(
this IResourceBuilder<NatsServerResource> builder,
string? srcMountPath = null)
{
// ...
}
}
builder IResourceBuilder<NatsServerResource> The resource builder.
srcMountPath string? optional Optional mount path providing persistence between restarts.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.
WithJetStream(IResourceBuilder<NatsServerResource>) Section titled WithJetStream(IResourceBuilder<NatsServerResource>) extension IResourceBuilder<NatsServerResource>
Adds JetStream support to the NATS server resource.
public static class NatsBuilderExtensions
{
public static IResourceBuilder<NatsServerResource> WithJetStream(
this IResourceBuilder<NatsServerResource> builder)
{
// ...
}
}
builder IResourceBuilder<NatsServerResource> The resource builder.
IResourceBuilder<NatsServerResource> The ApplicationModel.IResourceBuilder`1.