ReplicaSet.Aspire.MongoDB
1.0.0
dotnet add package ReplicaSet.Aspire.MongoDB --version 1.0.0
NuGet\Install-Package ReplicaSet.Aspire.MongoDB -Version 1.0.0
<PackageReference Include="ReplicaSet.Aspire.MongoDB" Version="1.0.0" />
<PackageVersion Include="ReplicaSet.Aspire.MongoDB" Version="1.0.0" />
<PackageReference Include="ReplicaSet.Aspire.MongoDB" />
paket add ReplicaSet.Aspire.MongoDB --version 1.0.0
#r "nuget: ReplicaSet.Aspire.MongoDB, 1.0.0"
#:package ReplicaSet.Aspire.MongoDB@1.0.0
#addin nuget:?package=ReplicaSet.Aspire.MongoDB&version=1.0.0
#tool nuget:?package=ReplicaSet.Aspire.MongoDB&version=1.0.0
ReplicaSet.Aspire.MongoDB
Provides the ability to create a MongoDB replica set for Aspire.
Use the extension method below to add a replica set to MongoDB when you want to specify the content path, dockerfile to override the location of the key file name
IResourceBuilder<MongoDBServerResource> WithReplicaSet(this IResourceBuilder<MongoDBServerResource> builder, string contextPath, string dockerFile, string keyFileName = "/etc/mongo-keyfile")
Alternatively if you want to use the Mongo.Dockerfile included with this NuGet package, you can use the extension method below. This method will try and locate the Mongo.Dockerfile in the same directory as the executing assembly.
IResourceBuilder<MongoDBServerResource> WithReplicaSet(this IResourceBuilder<MongoDBServerResource> builder)
Use the extension method AddMongoReplicaSet() to add a MongoDB replica set resource to the distributed application builder.
IResourceBuilder<MongoReplicaSetResource> AddMongoReplicaSet(this IDistributedApplicationBuilder builder, string name, IResourceWithConnectionString mongoDbResource)
A full example can be seen below when using the Mongo.Dockerfile provided with an example API Project:
var builder = DistributedApplication.CreateBuilder(args);
var username = builder.AddParameter("mongo-user", "admin");
var password = builder.AddParameter("mongo-password", "admin");
const int port = 27017;
var mongo = builder
.AddMongoDB("mongo", port, username, password)
.WithLifetime(ContainerLifetime.Persistent)
.WithReplicaSet();
var mongodb = mongo
.AddDatabase("mongoDatabase");
var mongoReplicaSet = builder
.AddMongoReplicaSet("mongoDb", mongodb.Resource);
builder.AddProject<AspireMongoReplicaSet_API>("aspiremongoreplicaset-api", "http")
.WithReference(mongodb)
.WithReference(mongoReplicaSet)
.WaitFor(mongodb)
.WaitFor(mongoReplicaSet);
await builder
.Build()
.RunAsync();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Aspire.Hosting (>= 9.1.0)
- Aspire.Hosting.MongoDB (>= 9.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 433 | 3/24/2025 |