After deploying a new Azure website that uses Azure AD to authenticate users with the OWIN authentication API, the login process started to fail. The login worked fine most of the time, but every so often, when logging in, the browser started an endless redirect loop after entering valid credentials. Once it starts, any login attempt results in the same endless redirect loop. Restarting the AppService "fixed" the problem temporarily until it started happening again.

After many google searches, I found the following permanent fix. Set the CookieAuthenticationOptions to use the SystemWebCookieManager.

Add a reference to Microsoft.Owin.Host.SystemWeb (version 3.1 or later), then,

Simply add "CookieManager = new SystemWebCookieManager()" in StartupAuth.cs as follows: