microsoft / microsoft/aspire

Cosmos DB Trigger is not work when using vNext Emulator with Aspire

Open
#16,195 1 comment 0 reactions 0 assignees View on GitHub
area-integrations internal-customer-impact
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

When using Azure Functions with Cosmos DB Trigger together with Aspire and the Cosmos DB Linux-based preview emulator (vNext), the Function App fails to start.
Specifically, the Cosmos DB Trigger fails during function indexing, which prevents the function from running at all.
This happens even though the Cosmos DB emulator is running successfully and the same connection works when using CosmosClient directly.
As a result, Cosmos DB Trigger is not usable in this setup.

### Expected Behavior
The Function App should start successfully, and the Cosmos DB Trigger should connect to the emulator using the endpoint and port specified in the connection string, allowing the trigger to initialize and process change feed events.

### Steps To Reproduce

Create an Aspire app using Aspire 13.2.0.
Configure Azure Cosmos DB using RunAsPreviewEmulator.
Create an Azure Functions (.NET isolated) project and add a CosmosDBTrigger.
Start the Aspire app.

### Exceptions (if any)

```
[2026-04-15T03:46:00.708Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.CloudPCChangeCapture'.
Microsoft.Azure.WebJobs.Extensions.CosmosDB:
Cannot create container information for cloudpcs in database cloudpc-db
with lease leases in database cloudpc-db:
No connection could be made because the target machine actively refused it.
(127.0.0.1:8081)

System.Net.Http: No connection could be made because the target machine actively refused it. (127.0.0.1:8081)
System.Net.Sockets: No connection could be made because the target machine actively refused it. (127.0.0.1:8081)
```

This error prevents the Function App from starting.
### Aspire doctor output

_No response_

### Anything else?

Additional details:

Connection string used by the Cosmos DB Trigger:
```
AccountEndpoint=https://localhost:49401;
AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==;
```

The endpoint https://localhost:49401/ is reachable and works correctly with CosmosClient.

Despite this, the Cosmos DB Trigger attempts to connect to 127.0.0.1:8081, which is not the configured port.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with Aspire 13.2.0, RunAsPreviewEmulator, and a .NET isolated Azure Functions app using a CosmosDBTrigger. Start at the Cosmos DB Trigger function-indexing and connection-string handling path; done means the trigger uses the configured https://localhost:49401 endpoint, the app starts, and change-feed processing can initialize without attempting 127.0.0.1:8081.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.