When you publish your site to Microsoft Azure with multiples domains pointing to the same site and turns on: Authentication-> Allow unauthenticated access (your site have public and private pages); Microsoft Azure randomly call back one of your Redirect URIs. To control this random behavior, you need to explicit set RedirectUri property base on Owin Context Request.

Don't ask me why, also you need to change URIs address removing “.auth/login/aad/callback” except for localhost. (If anyone knows the reason for this please let me know)
This works code works for me:
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
AuthenticationFailed = (context) =>
{
return System.Threading.Tasks.Task.FromResult(0);
},
RedirectToIdentityProvider = (context) =>
{
string strPostLogoutRedirectUri;
string strRedirectUri = EnsureTrailingSlash(context.OwinContext.Request.Uri.ToString());
int nPos = strRedirectUri.IndexOf("://");
if (nPos > 0)
{
nPos += 3;
strPostLogoutRedirectUri = "https://" + strRedirectUri.Substring(nPos, strRedirectUri.IndexOf("/", nPos) - nPos + 1);
strRedirectUri = strPostLogoutRedirectUri;
if (strRedirectUri.Contains("localhost"))
{
strRedirectUri = strPostLogoutRedirectUri + ".auth/login/aad/callback";
}
}
else
{
strRedirectUri = "https://YOURSITE.com/";
strPostLogoutRedirectUri = "https://YOURSITE.com/";
}
context.ProtocolMessage.RedirectUri = strRedirectUri;
context.ProtocolMessage.PostLogoutRedirectUri = strPostLogoutRedirectUri;
return System.Threading.Tasks.Task.FromResult(0);
}
}
}
);
// This makes any middleware defined above this line run before the Authorization rule is applied in web.config
app.UseStageMarker(PipelineStage.Authenticate);
}
private static string EnsureTrailingSlash(string value)
{
if (value == null)
{
value = string.Empty;
}
if (!value.EndsWith("/", StringComparison.Ordinal))
{
return value + "/";
}
return value;
}