Avoiding BuildServiceProvider() with IConfigureOptions
I wanted to configure ASP.NET Core Data Protection to persist keys to Redis using the Microsoft.AspNetCore.DataProtection.StackExchangeRedis package.
Using Aspire, it was easy to set up a Redis container in development, and the hosting package makes it simple to add a Redis client with logging, metrics, and resilience.
The problem was that PersistKeysToStackExchangeRedis only accepts a concrete IConnectionMultiplexer instance. There is no overload that takes a factory or resolves from the container, so the setup looked like this: