Watch Aspire live streamsDocsTry Aspire

MongoDBServerResource

Handle
📦 Aspire.Hosting.MongoDB v13.6.4
interface MongoDBServerResource
extends IComputeResource,
IExpressionValue,
IManifestExpressionProvider,
IResource,
IResourceWithArgs,
IResourceWithConnectionString,
IResourceWithEndpoints,
IResourceWithEnvironment,
IResourceWithProbes,
IResourceWithWaitSupport,
IValueProvider,
IValueWithReferences {
readonly connectionStringExpression: ReferenceExpression;
readonly databases: Dict<string,string>;
readonly host: EndpointReferenceExpression;
passwordParameter: ParameterResource;
readonly port: EndpointReferenceExpression;
readonly primaryEndpoint: EndpointReference;
replicaSetName: string;
readonly tlsEnabled: boolean;
readonly uriExpression: ReferenceExpression;
userNameParameter: ParameterResource;
readonly userNameReference: ReferenceExpression;
addDatabase(
name: string,
databaseName?: string): MongoDBDatabaseResource;
withBindIpAll(): MongoDBServerResource;
withDataBindMount(
source: string,
isReadOnly?: boolean): MongoDBServerResource;
withDataVolume(
name?: string,
isReadOnly?: boolean): MongoDBServerResource;
withInitFiles(source: string): MongoDBServerResource;
withKeyFile(
keyValue: IExpressionValue,
keyFilePath?: string): MongoDBServerResource;
withMongoExpress(configureContainer?: (obj: MongoExpressContainerResource) => Promise<void>, containerName?: string): MongoDBServerResource;
withRepl(): MongoDBServerResource;
withReplicaSet(name?: string): MongoDBServerResource;
withTlsAllowInvalidCertificates(): MongoDBServerResource;
withTlsMode(mode?: MongoDBTlsMode): MongoDBServerResource;
}

Properties

propertyconnectionStringExpressionReferenceExpressionget
Gets the connection string for the MongoDB server.
propertydatabasesDict<string,string>get
A dictionary where the key is the resource name and the value is the database name.
propertyhostEndpointReferenceExpressionget
Gets the host endpoint reference for this resource.
propertypasswordParameterParameterResourceget · set
Gets the parameter that contains the MongoDb server password.
propertyportEndpointReferenceExpressionget
Gets the port endpoint reference for this resource.
propertyprimaryEndpointEndpointReferenceget
Gets the primary endpoint for the MongoDB server.
propertyreplicaSetNamestringget · set
Gets the name of the replica set this MongoDB server belongs to, or `null` if it is not part of a replica set.
propertytlsEnabledbooleanget
Gets a value indicating whether TLS is enabled for the MongoDB server.
propertyuriExpressionReferenceExpressionget
Gets the connection URI expression for the MongoDB server.
propertyuserNameParameterParameterResourceget · set
Gets the parameter that contains the MongoDb server username.
propertyuserNameReferenceReferenceExpressionget
Gets a reference to the user name for the MongoDB server.

Methods

methodaddDatabasebuilder
Adds a MongoDB database to the application model.
addDatabase(
name: string,
databaseName?: string): MongoDBDatabaseResource
namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency.
databaseNamestringoptionalThe name of the database. If not provided, this defaults to the same value as `name`.
MongoDBDatabaseResource
methodwithBindIpAllbuilder
Configures the MongoDB server to bind to and listen on all network interfaces.
withBindIpAll(): MongoDBServerResource
MongoDBServerResource
methodwithDataBindMountbuilder
Adds a bind mount for the data folder to a MongoDB container resource.
withDataBindMount(
source: string,
isReadOnly?: boolean): MongoDBServerResource
sourcestringThe source directory on the host to mount into the container.
isReadOnlybooleanoptional= FalseA flag that indicates if this is a read-only mount.
MongoDBServerResource
methodwithDataVolumebuilder
Adds a named volume for the data folder to a MongoDB container resource.
withDataVolume(
name?: string,
isReadOnly?: boolean): MongoDBServerResource
namestringoptionalThe name of the volume. Defaults to an auto-generated name based on the application and resource names.
isReadOnlybooleanoptional= FalseA flag that indicates if this is a read-only volume.
MongoDBServerResource
methodwithInitFilesbuilder
Copies init files into a MongoDB container resource.
withInitFiles(source: string): MongoDBServerResource
sourcestringThe source file or directory on the host to copy into the container.
MongoDBServerResource
methodwithKeyFilebuilder
Sets up a keyfile for internal authentication between members of a MongoDB replica set, with the specified `keyValue` as the content of the file.
withKeyFile(
keyValue: IExpressionValue,
keyFilePath?: string): MongoDBServerResource
keyValueIExpressionValueThe content of the keyfile. This is a shared secret: every member of the replica set has to be given the same value, and anything holding it can authenticate as a member of the cluster.
keyFilePathstringoptional= /etc/rs.keyThe absolute path the keyfile is mounted at inside the container, which has to include a file name. Defaults to `/etc/rs.key`.
MongoDBServerResource
methodwithMongoExpressbuilder
Adds a MongoExpress administration and development platform for MongoDB to the application model.
withMongoExpress(configureContainer?: (obj: MongoExpressContainerResource) => Promise<void>, containerName?: string): MongoDBServerResource
configureContainer(obj: MongoExpressContainerResource) => Promise<void>optionalConfiguration callback for Mongo Express container resource.
containerNamestringoptionalThe name of the container (Optional).
MongoDBServerResource
methodwithReplbuilder
Adds a REPL command that opens an authenticated MongoDB shell in the dashboard terminal dock.
withRepl(): MongoDBServerResource
MongoDBServerResource
methodwithReplicaSetbuilder
Configures and initializes the MongoDB server as a single-member replica set for local development.
withReplicaSet(name?: string): MongoDBServerResource
namestringoptionalThe replica set name. Defaults to the resource name, or the name previously configured by this method.
MongoDBServerResource
Configures the MongoDB server to accept TLS connections whose peer certificate cannot be validated, by passing `--tlsAllowInvalidCertificates` to `mongod`.
withTlsAllowInvalidCertificates(): MongoDBServerResource
MongoDBServerResource
methodwithTlsModebuilder
Configures the `--tlsMode` the MongoDB server is started with when TLS is active.
withTlsMode(mode?: MongoDBTlsMode): MongoDBServerResource
modeMongoDBTlsModeoptional= RequireTlsThe TLS mode to run the MongoDB server in.
MongoDBServerResource