OWIN 在 Azure 中停止运行

OWIN stop functionning in Azure

我得到一个旧应用程序,运行 现在已经使用了 2 年,没有任何问题。最近登录部分开始失败,出现 404 Not found。 这里部分错误:

System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() +94579
Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__8.MoveNext() +375

[IOException: IDX20804: Unable to retrieve document from: '[PII is hidden]'.]
Microsoft.IdentityModel.Protocols.<GetDocumentAsync>d__8.MoveNext() +663
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
Microsoft.IdentityModel.Protocols.OpenIdConnect.<GetAsync>d__3.MoveNext() +291
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +102
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +64
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) +26
Microsoft.IdentityModel.Protocols.<GetConfigurationAsync>d__24.MoveNext() +1129

创建此 404 错误未找到的行是: HttpContext.GetOwinContext().Authentication.Challenge(authenticationProperties);

所以使用旧的 MSAL 和 OWIN 身份验证的 Azure 身份验证发生了一些变化(对于 B2C Azure) 在 B2C Azur 门户中,我可以在应用程序(旧版)中看到我的应用程序,并带有以下注释:新的应用程序注册体验现已普遍可用,并且是注册应用程序的推荐方式。单击应用程序注册边栏选项卡以访问新体验。应用程序(旧版)边栏选项卡已弃用,以后将不再可用。

很烦人,因为我不想花太多时间开发这个旧应用程序。我试图找到一些用于迁移此类应用程序的信息。我只需要在 AD B2C 中创建一个新应用程序吗?我是否必须更改我的代码? 谢谢

编辑1: 即登录按钮调用的代码。几个月前一切都在工作。大约 2 年来,我没有在这个项目上更改任何东西,也没有在 Azure 上推送任何东西!

    public void SignUpSignIn()
    {
        // Use the default policy to process the sign up / sign in flow
        if (!Request.IsAuthenticated)
        {
            string returnUrl = "/";
            if (Request.UrlReferrer.AbsolutePath != null && Request.UrlReferrer.AbsolutePath != "")
                returnUrl = Request.UrlReferrer.AbsolutePath;

            var authenticationProperties = new AuthenticationProperties { RedirectUri = returnUrl };
            HttpContext.GetOwinContext().Authentication.Challenge(authenticationProperties);
            return;
        }

编辑 2: 添加一些 PII 诊断后,我得到了这个细节: 无法从以下位置检索文档:'https://login.microsoftonline.com/tfp/hidenb2c.onmicrosoft.com/B2C_1_SignInOut/v2.0/.well-known/openid-configuration'

最后,经过多次尝试,我发现只需要把URL从

改成

https://login.microsoftonline.com/tfp/hidenb2c.onmicrosoft.com/B2C_1_SignInOut/v2.0/.well-known/openid-configuration

https://{tenant}.b2clogin.com/tfp/{tenant}.onmicrosoft.com/B2C_1_SignInOut/v2.0/.well-known/openid-configuration

现在一切正常。感谢您的帮助。