title: How to ensure "Always On" App Service starts automatically behind Azure AD
body: <p>I'm running a Spring Boot web app on a Windows / Java 11 / Tomcat 9.0 App Service, with the following settings:</p>
  <ul>
  <li>under the &quot;Configuration&quot; blade, &quot;General Settings&quot; tab
  <ul>
  <li>&quot;Always On&quot; is turned on</li>
  </ul>
  </li>
  <li>In the &quot;Authentication / Authorization&quot; blade
  <ul>
  <li>&quot;App Service Authentication&quot; is on</li>
  <li>&quot;Action to take when the request is not authenticated&quot; is set to &quot;Log in with Azure Active Directory&quot;</li>
  </ul>
  </li>
  </ul>
  <p>When restarting the app (e.g. on deploy) the app does not start up or log anything until an authenticated user hits the application. This is a major problem as the web app also runs background processes polling for messages which then just queue up until someone visits.</p>
  <p>Switching to Action to take when request is not authenticated to &quot;Allow anonymous (no action)&quot; resolves this issue, but isn't wanted for security reasons.</p>
  <p>According to <a href="https://docs.microsoft.com/en-us/azure/app-service/configure-common#configure-general-settings" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/app-service/configure-common#configure-general-settings</a>:</p>
  <blockquote>
  <p>With the Always On feature, the front end load balancer sends a request to the application root. This application endpoint of the App Service can't be configured.</p>
  </blockquote>
  <p>Hitting the application root does start it up, so I'm assuming that that initial request to the application root is being redirected to Azure AD and therefore not hitting the Java code and starting the service.</p>
  <p>How can I both configure the app to require login before even hitting the Java code, and ensure the app works &quot;Always On&quot;?</p>