Well this was weird mostly because it was working fine in local but not when deployed (and I still don't know why it worked locally). I suspect that there is some middleware that is running in IIS that is not running in IIS express that needs to resolve this type.

In general, if anything in middleware in the asp pipeline needs services injected, they need to be singletons. Why? Because there is no scope for the current request until much later but stuff needs to be added to these types in the pipeline. Transient won't work because the changes would be lost.

Answer, register middleware dependencies as Singletons and I was using IHttpContextAccessor (although not in middleware so who knows).

This is slightly weird because the content accessor sounds like a scoped service since the http context is scoped to the current request but the accessor itself is not the context and will take care of that.

services.AddHttpContextAccessor();

or

services.AddSingleton();

Nice!