Skip to content

CosmosDB Preview Emulator Regression from 13.1.2 to 13.2.0 - ContainerLifetime.Persistent does not keep the same container #15626

@AdamDotNet

Description

@AdamDotNet

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Set Cosmos DB emulator to RunAsPreviewEmulator and WithLifetime(ContainerLifetime.Persistent).

Start Aspire Host, CosmosDB container is created.
Stop Aspire Host.
Start Aspire Host, CosmosDB container is deleted and recreated.

Expected Behavior

Start Aspire Host, CosmosDB container is created.
Stop Aspire Host.
Start Aspire Host, CosmosDB keeps the same container running.

Steps To Reproduce

Repro video:

ReproCosmosDbContainerLifetime_720p.mp4

Attaching minimum repro that mirrors my real application in the parts that matter.

ReproCosmosDbContainerLifetime.zip

Snippet from the attached repro

var cosmosDb = builder.AddAzureCosmosDB(ServiceCosmosDb)
    // Preview emulator started working as of docker image published on November 18, 2025. If you have an older image, pull the latest mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
    .RunAsPreviewEmulator(configure =>
    {
        // Get the web UX to see data.
        // Only the preview emulator has a working data explorer.
        configure.WithDataExplorer(30052);
        // Keep the container running even when Aspire stops to speed up startup time.
        configure.WithLifetime(ContainerLifetime.Persistent);
        // When the data volume isn't persisted but the container is, then the port can change per Aspire run. Avoid that with a static port.
        configure.WithGatewayPort(30051);
    });

Exceptions (if any)

No response

.NET Version info

.Net 10.0.5
Image tag
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
sha256:5a880f416cd97dc1cb228c32ce7d36d76059d5b82c4f50bfa8f49d4db57daec5

Anything else?

VS Insiders [11619.145]

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions