Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.AppHost",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.ApiService", "playground\SqlServerEndToEnd\SqlServerEndToEnd.ApiService\SqlServerEndToEnd.ApiService.csproj", "{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mongo", "mongo", "{C544D8A6-977E-40EA-8B1A-1FB2146A2108}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mongo.AppHost", "playground\mongo\Mongo.AppHost\Mongo.AppHost.csproj", "{8F132275-233C-4121-AC6F-352C902FA064}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mongo.ApiService", "playground\mongo\Mongo.ApiService\Mongo.ApiService.csproj", "{40EC38A2-69DB-4759-81C8-13F31090FEA6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -565,6 +571,14 @@ Global
{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.Build.0 = Release|Any CPU
{8F132275-233C-4121-AC6F-352C902FA064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F132275-233C-4121-AC6F-352C902FA064}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F132275-233C-4121-AC6F-352C902FA064}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F132275-233C-4121-AC6F-352C902FA064}.Release|Any CPU.Build.0 = Release|Any CPU
{40EC38A2-69DB-4759-81C8-13F31090FEA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40EC38A2-69DB-4759-81C8-13F31090FEA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40EC38A2-69DB-4759-81C8-13F31090FEA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40EC38A2-69DB-4759-81C8-13F31090FEA6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -664,6 +678,9 @@ Global
{2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{7616FD70-6BEC-439D-B39E-A838F939C0F9} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD}
{78ABCF96-507B-4E5F-9265-CACC3EFD4C53} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD}
{C544D8A6-977E-40EA-8B1A-1FB2146A2108} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0}
{8F132275-233C-4121-AC6F-352C902FA064} = {C544D8A6-977E-40EA-8B1A-1FB2146A2108}
{40EC38A2-69DB-4759-81C8-13F31090FEA6} = {C544D8A6-977E-40EA-8B1A-1FB2146A2108}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C}
Expand Down
16 changes: 16 additions & 0 deletions playground/mongo/Mongo.ApiService/Mongo.ApiService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<NoWarn>$(NoWarn);CS8002</NoWarn> <!-- MongoDB packages are not signed -->
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Components\Aspire.MongoDB.Driver\Aspire.MongoDB.Driver.csproj" />
<ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions playground/mongo/Mongo.ApiService/Mongo.ApiService.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@CosmosEndToEnd.ApiService_HostAddress = http://localhost:5301

GET {{CosmosEndToEnd.ApiService_HostAddress}}/weatherforecast/
Accept: application/json

###
38 changes: 38 additions & 0 deletions playground/mongo/Mongo.ApiService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
using MongoDB.Driver;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
builder.AddMongoDBClient("mongo");

var app = builder.Build();

app.MapGet("/", async (IMongoClient mongoClient) =>
{
const string collectionName = "entries";

var db = mongoClient.GetDatabase("db");
await db.CreateCollectionAsync(collectionName);

// Add an entry to the database on each request.
var newEntry = new Entry();
await db.GetCollection<Entry>(collectionName).InsertOneAsync(newEntry);

var items = await db.GetCollection<Entry>(collectionName).FindAsync(_ => true);

return items.ToListAsync();
});

app.Run();

public class Entry
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
}
14 changes: 14 additions & 0 deletions playground/mongo/Mongo.ApiService/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5301",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/mongo/Mongo.ApiService/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
8 changes: 8 additions & 0 deletions playground/mongo/Mongo.AppHost/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />

<!-- NOTE: This line is only required because we are using P2P references, not NuGet. It will not exist in real apps. -->
<Import Project="../../../src/Aspire.Hosting/build/Aspire.Hosting.props" />

</Project>
9 changes: 9 additions & 0 deletions playground/mongo/Mongo.AppHost/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project>

<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />

<!-- NOTE: These lines are only required because we are using P2P references, not NuGet. They will not exist in real apps. -->
<Import Project="..\..\..\src\Aspire.Hosting\build\Aspire.Hosting.targets" />
<Import Project="..\..\..\src\Aspire.Hosting.Sdk\SDK\Sdk.targets" />

</Project>
23 changes: 23 additions & 0 deletions playground/mongo/Mongo.AppHost/Mongo.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\..\src\Aspire.Hosting\Utils\KnownResourceNames.cs" Link="KnownResourceNames.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspire.Dashboard\Aspire.Dashboard.csproj" />
<ProjectReference Include="..\..\..\src\Aspire.Hosting.Azure\Aspire.Hosting.Azure.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\..\..\src\Aspire.Hosting\Aspire.Hosting.csproj" IsAspireProjectResource="false" />

<ProjectReference Include="..\Mongo.ApiService\Mongo.ApiService.csproj" />
</ItemGroup>

</Project>
18 changes: 18 additions & 0 deletions playground/mongo/Mongo.AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddMongoDB("mongo");

builder.AddProject<Projects.Mongo_ApiService>("api")
.WithReference(db);

// This project is only added in playground projects to support development/debugging
// of the dashboard. It is not required in end developer code. Comment out this code
// to test end developer dashboard launch experience. Refer to Directory.Build.props
// for the path to the dashboard binary (defaults to the Aspire.Dashboard bin output
// in the artifacts dir).
builder.AddProject<Projects.Aspire_Dashboard>(KnownResourceNames.AspireDashboard);

builder.Build().Run();
29 changes: 29 additions & 0 deletions playground/mongo/Mongo.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175",
"DOTNET_ASPIRE_SHOW_DASHBOARD_RESOURCES": "true" // Display dashboard resource in console for local development
}
},
"generate-manifest": {
"commandName": "Project",
"launchBrowser": true,
"dotnetRunMessages": true,
"commandLineArgs": "--publisher manifest --output-path aspire-manifest.json",
"applicationUrl": "http://localhost:15888",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16175"
}
}
}
}
8 changes: 8 additions & 0 deletions playground/mongo/Mongo.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions playground/mongo/Mongo.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}