Aspire.Hosting.MongoDB 13.5.2

MongoDB hosting integration

Use this integration to model, configure, and orchestrate a MongoDB resource in an Aspire solution.

Getting started

Add the integration

From your AppHost directory, add the Aspire.Hosting.MongoDB integration with the Aspire CLI:

aspire add Aspire.Hosting.MongoDB

Usage example

In the AppHost, add a MongoDB resource and reference it from another resource with either C# or TypeScript:

C#

var db = builder.AddMongoDB("mongodb").AddDatabase("mydb");

var myService = builder.AddProject<Projects.MyService>()
                       .WithReference(db);

TypeScript

const db = await builder.addMongoDB("mongodb").addDatabase("mydb");

const myService = await builder.addNodeApp("myService", "../my-service", "server.js")
                       .withReference(db);

Connection Properties

When you reference a MongoDB resource using WithReference, the following connection properties are made available to the consuming project:

MongoDB server

The MongoDB server resource exposes the following connection properties:

Property Name Description
Host The hostname or IP address of the MongoDB server
Port The port number the MongoDB server is listening on
Username The username for authentication
Password The password for authentication (available when a password parameter is configured)
AuthenticationDatabase The authentication database (available when a password parameter is configured)
AuthenticationMechanism The authentication mechanism (available when a password parameter is configured)
Uri The connection URI, with the format mongodb://{Username}:{Password}@{Host}:{Port}/?authSource={AuthenticationDatabase}&authMechanism={AuthenticationMechanism}

MongoDB database

The MongoDB database resource combines the server properties above and adds the following connection property:

Property Name Description
DatabaseName The MongoDB database name

Aspire exposes each property as an environment variable named [RESOURCE]_[PROPERTY]. For instance, the Uri property of a resource called db1 becomes DB1_URI.

Additional documentation

Feedback & contributing

https://github.com/microsoft/aspire

No packages depend on Aspire.Hosting.MongoDB.

Version Downloads Last updated
13.5.3 1 08/29/2026
13.5.2 10 08/23/2026
13.5.1 9 08/21/2026
13.5.0 8 08/18/2026
13.4.6 16 06/23/2026
13.4.5 16 06/18/2026
13.4.4 14 06/16/2026
13.4.3 15 06/10/2026
13.4.2 16 06/05/2026
13.4.1 13 06/05/2026
13.4.0 16 06/05/2026
13.3.5 18 05/24/2026
13.3.4 15 05/23/2026
13.3.3 19 05/17/2026
13.3.2 19 05/17/2026
13.3.1 20 05/15/2026
13.3.0 18 05/11/2026
13.2.4 21 04/27/2026
13.2.3 22 04/27/2026
13.2.2 27 04/11/2026
13.2.1 32 04/02/2026
13.2.0 20 03/24/2026
13.1.3 26 03/22/2026
13.1.2 30 02/27/2026
13.1.1 27 02/14/2026
13.1.0 39 12/21/2025
13.0.2 50 12/11/2025
13.0.1 34 12/11/2025
13.0.0 28 12/13/2025
9.5.2 41 12/13/2025
9.5.1 35 12/10/2025
9.5.0 35 12/13/2025
9.4.2 28 12/13/2025
9.4.1 29 12/12/2025
9.4.0 32 12/13/2025
9.3.1 29 12/13/2025
9.3.0 36 12/15/2025
9.2.1 34 12/14/2025
9.2.0 30 12/13/2025
9.1.0 32 12/13/2025
9.0.0 34 01/05/2026
9.0.0-rc.1.24511.1 26 12/13/2025
8.2.2 36 12/13/2025
8.2.1 34 12/13/2025
8.2.0 27 12/13/2025
8.1.0 29 01/01/2026
8.0.2 33 12/13/2025
8.0.1 32 12/13/2025
8.0.0 29 12/13/2025
8.0.0-preview.7.24251.11 36 12/13/2025
8.0.0-preview.6.24214.1 30 12/22/2025
8.0.0-preview.5.24201.12 33 12/22/2025