microsoft / microsoft/aspire

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

Open
#6,740 1 comment 0 reactions 0 assignees View on GitHub
area-integrations azure azure-cosmosdb
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### 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 cosmos = builder.AddAzureCosmosDB(CosmosName)
.RunAsEmulator(e => e
.WithLifetime(ContainerLifetime.Persistent)
.WithDataVolume()
.WithPartitionCount(30)
.WithGatewayPort(8663));
```

We are using the following (relevant) Aspire packages:
- **Aspire.Hosting.AppHost** 9.0.0
- **Aspire.Hosting.Azure.CosmosDB** 9.0.0

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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.