Open bradygaster opened 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.
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.
I still see some build warnings and the test still isn't passing?
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.
Guess the emulator is broken on my machine. For once, it not working on my machine isn't a bad thing? :)
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.
Made a few small tweaks - otel refs and removal of the gRPC-related items in defaults.
@bradygaster @Pilchie I pushed some changes that hopefully make this more reliable:
DatabaseBootstrapper
using a Polly resiliency pipeline with enough retries and time to allow the emulator container to start (hopefully)DatabaseBootstrapper
from a raw IHostedService
to a BackgroundService
so its startup doesn't impact the lifecycle of the app. As it was, Kestrel couldn't start until the DatabaseBootstrapper
had successfully completed, and if it failed the app would just crash.DatabaseBootstrapper
double as an IHealthCheck
so it can report its status and the test can ensure /health succeeds before moving on to trying to hit /todosIt 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.
Adds Cosmos DB sample per #74