在'身份验证/授权'中配置时,外部身份验证无法正常工作Azure门户的设置

时间:2017-02-20 00:11:52

标签: azure authentication asp.net-core

虽然我的ASP.NET Core网站本地工作得很好,但是在将其发布到Azure时遇到了内部服务器错误("启动应用程序时出错。")。我.CaptureStartupErrors(true).UseSetting("detailedErrors","true")WebHostBuilder传递给Program.cs中的System.ArgumentException: The 'ClientId' option must be provided.

Configure()

这是指Startup.csapp.UseGoogleAuthentication( new GoogleOptions() { ClientId = Configuration[ "Authentication:Google:ClientId" ], ClientSecret = Configuration[ "Authentication:Google:ClientSecret" ] } ); 的一部分中的Google身份验证选项。

Startup()

在开发期间,使用if ( env.IsDevelopment() ) { builder.AddUserSecrets<Startup>(); } 中的用户机密

成功加载了这些内容
ClientId

found out more details on the exact errorClientSecretsample = ggplot(data=data.frame(x=runif(10),y=runif(10)),aes(x,y)) + geom_point(aes(color=x)) 应在Azure门户中的“身份验证/授权”下指定。的网络应用程序设置。即使我最初在那里指定,但例外仍然存在。

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

'身份验证/授权'设置似乎只是设置环境变量的一个令人愉快的前端。这没有很好的记录。或者,可以在(不含名称)'应用程序设置 - &gt;应用程序设置'中设置这些。

虽然external authentication provider tutorial for Google建议使用Authentication:Google:ClientIdAuthentication:Google:ClientSecret作为环境变量的键,但这些不是由Azure中的身份验证菜单设置的键。

如果您要加载在身份验证菜单中设置的值(而不是仅在“应用设置”中设置自己的键),您需要确定哪个环境它设定的变量。

使用PowerShell中的Get-ChildItem Env:快速列出所有变量('Kudu',可从Azure上的'高级工具'访问)列出了应该使用的变量:

app.UseGoogleAuthentication( new GoogleOptions()
{
    ClientId = Configuration[ "WEBSITE_AUTH_GOOGLE_CLIENT_ID" ],
    ClientSecret = Configuration[ "WEBSITE_AUTH_GOOGLE_CLIENT_SECRET" ]
} );

不要忘记更新存储在用户秘密中的密钥!

P.S。奇怪的是,当我第一次尝试使用“应用程序设置”设置变量时,它们在重新加载菜单时就消失了。只是一个抬头,这个界面似乎有点儿麻烦。