aspire-samples icon indicating copy to clipboard operation
aspire-samples copied to clipboard

Add sample to use Aspire with CosmosDB

Open Kralizek opened this issue 1 year ago • 11 comments

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

Kralizek avatar Dec 27 '23 14:12 Kralizek

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

DamianEdwards avatar Jan 09 '24 16:01 DamianEdwards

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

Pilchie avatar Jan 09 '24 17:01 Pilchie

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

bradygaster avatar Feb 09 '24 21:02 bradygaster

You're the best @bradygaster !

Pilchie avatar Feb 09 '24 21:02 Pilchie

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.

chrisrlewis avatar Feb 27 '24 09:02 chrisrlewis

@bradygaster you still planning on doing this one?

DamianEdwards avatar Mar 09 '24 16:03 DamianEdwards

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

bradygaster avatar Jun 10 '24 21:06 bradygaster

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/

bradygaster avatar Jun 11 '24 20:06 bradygaster

LGTM. Thanks @bradygaster.

Pilchie avatar Jun 11 '24 21:06 Pilchie

Love it. Thanks @bradygaster !!!

markjbrown avatar Jun 13 '24 11:06 markjbrown

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

Kralizek avatar Jul 12 '24 16:07 Kralizek