dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.93k stars 480 forks source link

[Aspire.Microsoft.Azure.Cosmos] How to access the CosmosDB emulator data explorer? #5163

Open hansmbakker opened 3 months ago

hansmbakker commented 3 months ago

The Aspire.Microsoft.Azure.Cosmos component provides the

cosmosdb.RunAsEmulator();

method. Aspire.NET does recognize the 8081 port in the container (see screenshot). However, without any additional settings the emulator will only be exposed via a TCP endpoint which is not enough to access the data explorer dashboard from the emulator.

How can I expose the data explorer inside the emulator container best, during development? Can you please add this to the documentation?

image

hansmbakker commented 3 months ago

A possible option I saw was doing the following:

var cosmos = builder.AddAzureCosmosDB("CosmosDb")
                                  .AddDatabase("mydatabase");

if (builder.Environment.IsDevelopment())
{
    cosmos.WithHttpsEndpoint(8081, 8081, "emulator-port")
          .RunAsEmulator();
}

However, doing the thing above results in 8081 being listed twice and it adds another emulator-port target port than I specified (see screenshot).

I would like to be confirmed that this is the correct approach, and have it in the documentation for reference.

image