dotnet / aspire-samples

MIT License
560 stars 153 forks source link

added cosmosdb sample #321

Open bradygaster opened 3 weeks ago

bradygaster commented 3 weeks ago

Adds Cosmos DB sample per #74

DamianEdwards commented 3 weeks ago

@bradygaster you'll need to figure out how to make this sample pass the test cleanly as currently the apiservice fails to start it seems.

bradygaster commented 3 weeks ago

Pretty sure I captured all the changes suggested by @DamianEdwards and @Pilchie save 1 - i couldn't get the app to work properly when i have RunAsEmulator in the App Host code. If @Pilchie has guidance on how to work past the error i've sent him i'll implement it, otherwise i think this has everything everyone requested and is ready to go.

DamianEdwards commented 3 weeks ago

I still see some build warnings and the test still isn't passing?

bradygaster commented 3 weeks ago

added the RunAsEmulator command as it matches the implementation in the playground project and the comment @DamianEdwards requested, in lieu of the fact that i couldn't get it working with the emulator.

bradygaster commented 3 weeks ago

Guess the emulator is broken on my machine. For once, it not working on my machine isn't a bad thing? :)

DamianEdwards commented 3 weeks ago

Only thing left would be to add a test case at https://github.com/dotnet/aspire-samples/blob/main/tests/SamplesIntegrationTests/AppHostTests.cs#L125 so that we get proper coverage of this new sample.

bradygaster commented 3 weeks ago

Made a few small tweaks - otel refs and removal of the gRPC-related items in defaults.

DamianEdwards commented 2 weeks ago

@bradygaster @Pilchie I pushed some changes that hopefully make this more reliable:

It seems problematic that the Cosmos DB component doesn't enable enough retries by default to allow the emulator to startup. Also I found it confusing that the Cosmos DB resource reports itself as having only a TCP endpoint but then it clearly uses HTTP at runtime, but because it doesn't use IHttpClientFactory it doesn't get any of the default Aspire HTTP resiliency applied. I attempted to wire the Cosmos client up to IHttpClientFactory but found it more complex than simply wrapping retries around the creation logic due to having to separate it from the default resiliency (as that wasn't resilient enough) and having to manually handle the HTTPS cert again.