So we have developed an ASP.NET Core Web Application. It's an Employee Directory app which requires Windows Authentication. But within this Web Application resides a HostedService which implements BackgroundService. This background service will call graph API every hour looking for any user changes and if any exist download the user's photos. Everything is configured correctly within IIS between the application and also the app Pool. But the Background service will not start until I navigate to the page, once this is done it will continue to run every hour. If I stop/recycle the app pool, the background service will stop and not restart, not until again navigating to the website.
However, if I enabled Anonymous Authentication, and then recycle the app pool, the hosted service starts successfully.
Is Anonymous Authentication required when using a BackgroundService and setting the following; Preload Enabled: True
App Pool; .NET CLR Version: v4.0 Start Mode: AlwaysRunning Idle Time-out: 0