# MongoDBReplicaSetResource Constructors

- Package: [Aspire.Hosting.MongoDB](/reference/api/csharp/aspire.hosting.mongodb.md)
- Type: [MongoDBReplicaSetResource](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource.md)
- Kind: `Constructors`
- Members: `1`

Represents a MongoDB replica set resource in the application model. A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and high availability.

<a id="constructor"></a>
<a id="constructor-string-parameterresource-parameterresource-parameterresource"></a>

## MongoDBReplicaSetResource(string, ParameterResource, ParameterResource?, ParameterResource)

- Name: `Constructor(string, ParameterResource, ParameterResource?, ParameterResource)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting.MongoDB/ReplicaSet/MongoDBReplicaSetResource.cs#L27-L67)

Represents a MongoDB replica set resource in the application model. A replica set is a group of MongoDB servers that maintain the same data set, providing redundancy and high availability.

```csharp
public sealed class MongoDBReplicaSetResource
{
    public MongoDBReplicaSetResource(
        string name,
        ParameterResource keyFile,
        ParameterResource? sharedUserName,
        ParameterResource sharedPassword)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the resource, which is also the name of the replica set itself.
- `keyFile` (`ParameterResource`)
  The content of the keyfile the members use to authenticate to each other. Required.
- `sharedUserName` (`ParameterResource?`)
  The user name every member authenticates with, or `null` to use the default user name.
- `sharedPassword` (`ParameterResource`)
  The password every member authenticates with. Required.

## Remarks

This resource is a logical grouping of multiple [MongoDBServerResource](/reference/api/csharp/aspire.hosting.mongodb/mongodbserverresource.md) instances that are configured as members of the same replica set.
