# MongoDBReplicaSetResource

- Kind: `class`
- Package: [Aspire.Hosting.MongoDB](/reference/api/csharp/aspire.hosting.mongodb.md)
- Version: `13.6.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting.MongoDB/ReplicaSet/MongoDBReplicaSetResource.cs)
- Inherits: `Resource`
- Implements: `IExpressionValue`, `IManifestExpressionProvider`, `IResource`, `IResourceWithConnectionString`, `IResourceWithWaitSupport`, `IValueProvider`, `IValueWithReferences`

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.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class MongoDBReplicaSetResource
    : Aspire.Hosting.ApplicationModel.Resource,
      Aspire.Hosting.ApplicationModel.IExpressionValue,
      Aspire.Hosting.ApplicationModel.IManifestExpressionProvider,
      Aspire.Hosting.ApplicationModel.IResource,
      Aspire.Hosting.ApplicationModel.IResourceWithConnectionString,
      Aspire.Hosting.ApplicationModel.IResourceWithWaitSupport,
      Aspire.Hosting.ApplicationModel.IValueProvider,
      Aspire.Hosting.ApplicationModel.IValueWithReferences
{
    // ...
}
```

## ATS metadata

### ATS export

- Type ID: `Aspire.Hosting.MongoDB/MongoDBReplicaSetResource`
- Public instance properties are exported as ATS capabilities.

## 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.

## Constructors

- [MongoDBReplicaSetResource(string, ParameterResource, ParameterResource?, ParameterResource)](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/constructors.md#constructor-string-parameterresource-parameterresource-parameterresource) -- 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.

## Properties

- [ConnectionStringExpression](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#connectionstringexpression) : `ReferenceExpression` `get` -- Gets the combined connection string for the MongoDB replica set, which includes the endpoints of all members, interpretable by the MongoDB driver.
- [Members](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#members) : [IEnumerable<MongoDBServerResource>](/reference/api/csharp/aspire.hosting.mongodb/mongodbserverresource.md) `get` -- Gets the MongoDB server resources that are members of this replica set, in the order they were added.
- [SharedKeyFileParameter](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#sharedkeyfileparameter) : `ParameterResource` `get` -- Gets the parameter that contains the content of the key file used for internal authentication between members of the MongoDB replica set.
- [SharedPasswordParameter](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#sharedpasswordparameter) : `ParameterResource` `get` -- Gets the parameter that contains the password for authenticating to the MongoDB replica set.
- [SharedUserNameParameter](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#sharedusernameparameter) : `ParameterResource?` `get` -- Gets the parameter that contains the username for authenticating to the MongoDB replica set.
- [SharedUserNameReference](/reference/api/csharp/aspire.hosting.mongodb/mongodbreplicasetresource/properties.md#sharedusernamereference) : `ReferenceExpression` `get` -- Gets a reference to the username for the MongoDB replica set.
