You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ReplicaSet.Aspire.MongoDB

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ReplicaSet.Aspire.MongoDB

Add replica set to MongoDB when using Aspire

1.0.0
nugetNuGet
Version published
Maintainers
1
Created
Source

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();

Keywords

FAQs

Package last updated on 24 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.