-
Couldn't load subscription status.
- Fork 712
Description
The next step after EventHubs, ServiceBus, and CosmosDB Hosting integrations should create Resources for children (dotnet/aspire#7407) is that we should support "deep linking" to the child resources and have corresponding client integration APIs for adding the child directly.
For example, in CosmosDB:
AppHost
var cosmos = builder.AddAzureCosmosDB("cosmos")
.RunAsPreviewEmulator(e => e.WithDataExplorer());
var db = cosmos.AddCosmosDatabase("db");
var entries = db.AddContainer("entries", "/id");
builder.AddProject<Projects.CosmosEndToEnd_ApiService>("api")
.WithExternalHttpEndpoints()
.WithReference(cosmos) // adds 'cosmos' connection string pointing to root service
.WithReference(db) // adds 'db' connection string pointing to the root service + ";Database=db"
.WithReference(entries); // adds 'entries' connection string pointing to the root service + ";Database=db" + ";Container=entries"Then on the app side, we should have corresponding APIs for directly referencing these children:
builder.AddAzureCosmosClient("cosmos"); // exists today
builder.AddAzureCosmosDatabaseClient("db"); // new, registers a Microsoft.Azure.Cosmos.Database in DI
builder.AddAzureCosmosContainerClient("entries"); // new, registers a Microsoft.Azure.Cosmos.Container in DIOn CosmosDB EF, this will simply the existing code:
builder.AddCosmosDbContext<TestCosmosContext>("cosmos", "db"); // today
builder.AddCosmosDbContext<TestCosmosContext>("db"); // new - gets all connection information from the 'db' connection stringQUESTION: What happens if you AddCosmosDbContext to a "container"? Today AFAIK EF defaults to using the DbContext TypeName as the container name. Maybe we can change that to the specified container if you deep-link to that container.
We should do similar APIs for EventHubs and ServiceBus as well, where it makes sense.
We should also remember to update the Azure Functions config support as well.
Resource Types Requiring Support
- CosmosDB
- Service Bus
- EventHubs
- Azure Storage
- OpenAI Configure OpenAI models in the app host #6577
- Azure WebPubSub Hub