dotnet / aspire

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

Issue with Persistent Cosmos DB Container Restart in Aspire (.NET 9) #6740

Open Thovenaar opened 1 day ago

Thovenaar commented 1 day ago

Is there an existing issue for this?

Describe the bug

Dear Support Team,

I hope this message finds you well.

We are currently encountering an issue with Aspire while using Cosmos DB in a .NET 9 project. The problem occurs with the Cosmos DB container configured as persistent. While it functions correctly during the initial startup, it fails upon subsequent restarts—either triggered manually via Docker or after a system reboot. Specifically, the container hangs at approximately 75% completion during startup.

Below is the relevant code snippet from the project setup:

IResourceBuilder<AzureCosmosDBResource> cosmos = builder.AddAzureCosmosDB(CosmosName)
    .RunAsEmulator(e => e
        .WithLifetime(ContainerLifetime.Persistent)
        .WithDataVolume()
        .WithPartitionCount(30)
        .WithGatewayPort(8663));

We are using the following (relevant) Aspire packages:

For reference, these are the container logs during the second startup (after the initial successful session):

2024-11-20 12:07:54 This is an evaluation version.  There are [124] days left in the evaluation period.
2024-11-20 12:07:55 2.14.20.0 (dd7750b6)
2024-11-20 12:07:55 Copyright (C) Microsoft Corporation. All rights reserved.
2024-11-20 12:07:56 Starting
2024-11-20 12:08:26 Started 1/31 partitions
2024-11-20 12:08:26 Started 2/31 partitions
2024-11-20 12:08:27 Started 3/31 partitions
2024-11-20 12:08:27 Started 4/31 partitions
2024-11-20 12:08:27 Started 5/31 partitions
2024-11-20 12:08:28 Started 6/31 partitions
2024-11-20 12:08:28 Started 7/31 partitions
2024-11-20 12:08:28 Started 8/31 partitions
2024-11-20 12:08:29 Started 9/31 partitions
2024-11-20 12:08:29 Started 10/31 partitions
2024-11-20 12:08:29 Started 11/31 partitions
2024-11-20 12:08:29 Started 12/31 partitions
2024-11-20 12:08:30 Started 13/31 partitions
2024-11-20 12:08:30 Started 14/31 partitions
2024-11-20 12:08:30 Started 15/31 partitions
2024-11-20 12:08:31 Started 16/31 partitions
2024-11-20 12:08:31 Started 17/31 partitions
2024-11-20 12:08:32 Started 18/31 partitions
2024-11-20 12:08:32 Started 19/31 partitions
2024-11-20 12:08:32 Started 20/31 partitions
2024-11-20 12:08:33 Started 21/31 partitions
2024-11-20 12:08:33 Started 22/31 partitions
2024-11-20 12:08:33 Started 23/31 partitions
2024-11-20 12:08:33 Started 24/31 partitions

We would greatly appreciate your assistance in identifying the root cause of this issue and any guidance on resolving it. Please let us know if additional information or logs are required.

Best regards, Thovenaar

Expected Behavior

The Cosmos DB container configured with Aspire should function correctly across all sessions, regardless of restarts triggered manually through Docker or via system reboots. Specifically:

  1. The Cosmos DB container should initialize and reach 100% startup completion consistently after any restart.
  2. The persistent configuration should ensure that data, volume mappings, and partition settings remain intact and accessible across sessions.
  3. The startup process should not hang or experience significant delays, ensuring seamless operation and availability of the Cosmos DB emulator.

This behavior should align with the provided Aspire configuration and package versions, without requiring additional manual intervention.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

.NET 9

Anything else?

No response