Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

MongoDBServerResource

Handle
📦 Aspire.Hosting.MongoDB v17.0.0

A resource that represents a MongoDB container.

type MongoDBServerResource interface {
ExpressionValue
IComputeResource
Resource
ResourceWithArgs
ResourceWithConnectionString
ResourceWithEndpoints
ResourceWithEnvironment
ResourceWithWaitSupport
}

Properties

propertyConnectionStringExpression*ReferenceExpressionget
Gets the connection string for the MongoDB server.
ConnectionStringExpression() *ReferenceExpression
propertyDatabasesmap[string]stringget
A dictionary where the key is the resource name and the value is the database name.
Databases() (map[string]string, error)
propertyHostEndpointReferenceExpressionget
Gets the host endpoint reference for this resource.
Host() EndpointReferenceExpression
propertyPasswordParameterParameterResourceget · set
Gets the parameter that contains the MongoDb server password.
PasswordParameter() ParameterResource
SetPasswordParameter(value ParameterResource) MongoDBServerResource
propertyPortEndpointReferenceExpressionget
Gets the port endpoint reference for this resource.
Port() EndpointReferenceExpression
propertyPrimaryEndpointEndpointReferenceget
Gets the primary endpoint for the MongoDB server.
PrimaryEndpoint() EndpointReference
propertyReplicaSetName*stringget · set
Gets the name of the replica set this MongoDB server belongs to, or null if it is not part of a replica set.
ReplicaSetName() (*string, error)
SetReplicaSetName(value *string) MongoDBServerResource
propertyResourceTypeDisplayNamestringget
Gets the ResourceTypeDisplayName property
ResourceTypeDisplayName() (string, error)
propertyTlsEnabledboolget
Gets a value indicating whether TLS is enabled for the MongoDB server.
TlsEnabled() (bool, error)
propertyUriExpression*ReferenceExpressionget
Gets the connection URI expression for the MongoDB server.
UriExpression() *ReferenceExpression
propertyUserNameParameterParameterResourceget · set
Gets the parameter that contains the MongoDb server username.
UserNameParameter() ParameterResource
SetUserNameParameter(value ParameterResource) MongoDBServerResource
propertyUserNameReference*ReferenceExpressionget
Gets a reference to the user name for the MongoDB server.
UserNameReference() *ReferenceExpression

Methods

methodAddDatabasebuilder
Adds a MongoDB database to the application model.
AddDatabase(
name string,
options ...*AddDatabaseOptions,
) MongoDBDatabaseResource
namestringThe name of the resource. This name will be used as the connection string name when referenced in a dependency.
options...*AddDatabaseOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*AddDatabaseOptions argument.

DatabaseName*stringThe name of the database. If not provided, this defaults to the same value as name.
MongoDBDatabaseResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithBindIpAllbuilder
Configures the MongoDB server to bind to and listen on all network interfaces.
WithBindIpAll() MongoDBServerResource
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithDataBindMountbuilder
Adds a bind mount for the data folder to a MongoDB container resource.
WithDataBindMount(
source string,
options ...*WithDataBindMountOptions,
) MongoDBServerResource
sourcestringThe source directory on the host to mount into the container.
options...*WithDataBindMountOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithDataBindMountOptions argument.

IsReadOnly*boolA flag that indicates if this is a read-only mount.
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithDataVolumebuilder
Adds a named volume for the data folder to a MongoDB container resource.
WithDataVolume(options ...*WithDataVolumeOptions) MongoDBServerResource
options...*WithDataVolumeOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithDataVolumeOptions argument.

Name*stringThe name of the volume. Defaults to an auto-generated name based on the application and resource names.
IsReadOnly*boolA flag that indicates if this is a read-only volume.
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

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

The resource builder.

Returns a handle; failures surface later via Err().

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 ExpressionValue,
options ...*WithKeyFileOptions,
) MongoDBServerResource
keyValueExpressionValueThe 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.
options...*WithKeyFileOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithKeyFileOptions argument.

KeyFilePath*stringThe absolute path the keyfile is mounted at inside the container, which has to include a file name. Defaults to /etc/rs.key.
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithMongoExpressbuilder
Adds a MongoExpress administration and development platform for MongoDB to the application model.
WithMongoExpress(options ...*WithMongoExpressOptions) MongoDBServerResource
options...*WithMongoExpressOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithMongoExpressOptions argument.

ConfigureContainerfunc(obj MongoExpressContainerResource)callbackConfiguration callback for Mongo Express container resource.
ContainerName*stringThe name of the container (Optional).
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithReplbuilder
Adds a REPL command that opens an authenticated MongoDB shell in the dashboard terminal dock.
WithRepl() MongoDBServerResource
MongoDBServerResource

The resource builder for chaining.

Returns a handle; failures surface later via Err().

methodWithReplicaSetbuilder
Configures and initializes the MongoDB server as a single-member replica set for local development.
WithReplicaSet(options ...*WithReplicaSetOptions) MongoDBServerResource
options...*WithReplicaSetOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithReplicaSetOptions argument.

Name*stringThe replica set name. Defaults to the resource name, or the name previously configured by this method.
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

Configures the MongoDB server to accept TLS connections whose peer certificate cannot be validated, by passing --tlsAllowInvalidCertificates to mongod.
WithTlsAllowInvalidCertificates() MongoDBServerResource
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithTlsModebuilder
Configures the --tlsMode the MongoDB server is started with when TLS is active.
WithTlsMode(options ...*WithTlsModeOptions) MongoDBServerResource
options...*WithTlsModeOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithTlsModeOptions argument.

Mode*MongoDBTlsModeThe TLS mode to run the MongoDB server in.
MongoDBServerResource

The resource builder.

Returns a handle; failures surface later via Err().