dotnet / aspire-samples

MIT License
607 stars 173 forks source link

Add sample to use Aspire with CosmosDB #74

Open Kralizek opened 8 months ago

Kralizek commented 8 months ago

I would appreciate if there was a sample showing how to use CosmosDB in Aspire since this simple setup isn't working and I have no clue on what's missing.

var builder = DistributedApplication.CreateBuilder(args);

var db = builder.AddAzureCosmosDB("db");

var api = builder.AddProject<Projects.API>("api")
    .WithReference(db);

builder.Build().Run();

See: https://github.com/dotnet/aspire/issues/1502

DamianEdwards commented 7 months ago

Thanks for the suggestion. @bradygaster mind taking this one? Or perhaps @Pilchie?

Pilchie commented 7 months ago

I want to do this, but need to be honest that it likely won't be this month. In the meantime, if you check out some of the earlier commits of https://github.com/dotnet/aspire/pull/359, it did have some apps in the main app. For example: https://github.com/dotnet/aspire/pull/359/commits/4f01310c85336c8595a7314e4f0e1ef255148796

bradygaster commented 6 months ago

I can do this. I'll have it by end of next week, apologies for the delay.

Pilchie commented 6 months ago

You're the best @bradygaster !

chrisrlewis commented 6 months ago

I can do this. I'll have it by end of next week, apologies for the delay.

@bradygaster I'm also looking forward to this, as currently struggling with starting with Cosmos db + Aspire. If the example could include the various ways to connect and also include the required config file settings that would be perfect.

DamianEdwards commented 5 months ago

@bradygaster you still planning on doing this one?

bradygaster commented 2 months ago

I can do it if we didn't get one done. I started adding it to an app but got side-tracked.

bradygaster commented 2 months ago

Update to @DamianEdwards and @Pilchie and @markjbrown that I've created the sample with some help from the nice folks in Cosmos DB.

Let me know (in the form of a pull request or issue) if there's anything else y'all think this needs, or any tweaks, and I'll facilitate.

Also to @chrisrlewis - not sure if this satisfies your desire for "all the ways to connect," but I wanted to share this with you to see if this helps at all.

https://github.com/bradygaster/CosmosWithAspire

App is running here for those who'd like to try it out. Please be nice. :)

https://webfrontend.wonderfulsky-9bb53c18.westus.azurecontainerapps.io/

Pilchie commented 2 months ago

LGTM. Thanks @bradygaster.

markjbrown commented 2 months ago

Love it. Thanks @bradygaster !!!

Kralizek commented 1 month ago

would it be possible to expand the example with the use of the local emulator and entity framework?