Should it be possible to call an AWS service within Startup.ConfigureServices? #1732
-
We found it would be nice to load some app settings from AWS AppConfig at startup, in order to then configure some dependencies in the service collection (eg. logging, Polly retry policies, HttpClientFactory settings, etc). It seems than when we try to access an AWS service from within ConfigureServices, nothing in that method executes after the attempt, and the function is called while missing some dependencies, and obviously fails. We've confirmed that we can remove the annotations and essentially craft our own "generated" class that makes those calls prior to calling ConfigureServices (and passing the loaded configuration), and it works just fine, so maybe all we need is another hook in Startup (eg |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Actually, I think part of the failure here was related to a permissions issue when calling AppConfig. After resolving that it seems to work as expected. |
Beta Was this translation helpful? Give feedback.
-
Another twist to doing this is that the generated class cannot await the call to ConfigureServices if you define it as |
Beta Was this translation helpful? Give feedback.
Actually, I think part of the failure here was related to a permissions issue when calling AppConfig. After resolving that it seems to work as expected.