Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have a very simple demo app here: https://github.com/mwiedemeyer/AspireDemo
Updated to Aspire 9.1
In the AppHost I add a CosmosDB resource with
var cosmos = builder.AddAzureCosmosDB("cosmos")
.RunAsPreviewEmulator(p => p.WithDataExplorer().WithDataVolume().WithLifetime(ContainerLifetime.Persistent))
.AddCosmosDatabase("db")
.AddContainer("users", "/id");
In my client a try to add a cosmos EF context with:
builder.AddCosmosDbContext<AppDbContext>("cosmos", "db");
However it fails, because it cannot find the connection string.
In the env variables of my client it shows only these connection strings mapping to the cosmos db:
Aspire__Microsoft__Azure__Cosmos__users__ConnectionString
users
The client fails with this error message:
'A DbContext could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:cosmos' or either ConnectionString or AccountEndpoint must be provided in the 'Aspire:Microsoft:EntityFrameworkCore:Cosmos' or 'Aspire:Microsoft:EntityFrameworkCore:Cosmos:AppDbContext' configuration section.'
So the names do not match. Is there anything I need to do to fix it?
I also tried this one, but it fails either:
builder.AddCosmosDbContext<AppDbContext>("users", "db");
Expected Behavior
I expect the documented version to work like in the description above
Steps To Reproduce
Run the demo project from here https://github.com/mwiedemeyer/AspireDemo
Then open the console logs for the func and click on the link (something like http://localhost:7184/api/Function1
)
Exceptions (if any)
InvalidOperationException
'A DbContext could not be configured. Ensure valid connection information was provided in 'ConnectionStrings:cosmos' or either ConnectionString or AccountEndpoint must be provided in the 'Aspire:Microsoft:EntityFrameworkCore:Cosmos' or 'Aspire:Microsoft:EntityFrameworkCore:Cosmos:AppDbContext' configuration section.'
.NET Version info
.NET SDK:
Version: 9.0.200
Commit: 90e8b202f2
Workload version: 9.0.200-manifests.c4f6226a
MSBuild version: 17.13.8+cbc39bea8
Anything else?
Aspire 9.1 just updated after the release yesterday. Working with Visual Studio.
Activity