【问题标题】:Getting UnauthorizedAccessException when deploying asp.net core app using Kudu build service使用 Kudu 构建服务部署 asp.net 核心应用程序时出现 UnauthorizedAccessException
【发布时间】:2020-04-11 22:00:34
【问题描述】:

我已经使用 Kudu 构建服务(直接通过 GitHub 连接)设置了我的 aspnet core 2.2 应用程序的持续部署。直到前天还好,但是当我从昨天开始尝试部署任何东西时,开始收到UnauthorizedAccessException。不过,我的应用程序没有任何变化。知道这里有什么问题吗??

这里是详细的异常:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
   at Internal.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
   at Internal.Win32.RegistryKey.SetValue(String name, String value)
   at System.Environment.SetEnvironmentVariableFromRegistry(String variable, String value, Boolean fromMachine)
Failed exitCode=1, command=dotnet restore "D:\home\site\repository\myproject.sln"
   at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
An error has occurred during web site deployment.
   at Microsoft.DotNet.Cli.Utils.EnvironmentProvider.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
   at Microsoft.DotNet.ShellShim.WindowsEnvironmentPath.AddPackageExecutablePathToUserPath()
   at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
   at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)
System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.\r\n   at Internal.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)\r\n   at Internal.Win32.RegistryKey.SetValue(String name, String value)\r\n   at System.Environment.SetEnvironmentVariableFromRegistry(String variable, String value, Boolean fromMachine)\r\n   at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)\r\n   at Microsoft.DotNet.Cli.Utils.EnvironmentProvider.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)\r\n   at Microsoft.DotNet.ShellShim.WindowsEnvironmentPath.AddPackageExecutablePathToUserPath()\r\n   at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()\r\n   at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)\r\n   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)\r\n   at Microsoft.DotNet.Cli.Program.Main(String[] args)\r\nD:\Program Files (x86)\SiteExtensions\Kudu\86.20224.4450\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"

【问题讨论】:

  • 由于你没有做任何改动,所以我的建议是保证代码正常,你可以先尝试断开Github,然后设置Github进行持续部署。跨度>

标签: asp.net-core azure-web-app-service kudu


【解决方案1】:

在 kudu 中尝试“dotnet restore --help”并得到相同的错误后,我意识到该错误与在 kudu 中执行“dotnet restore”有关,而不是与我的应用程序有关。 看了错误信息相关的代码后 https://github.com/dotnet/sdk/blob/5d747e7b4f1450a00eff5844bd76b73588531b2c/src/Cli/dotnet/Program.cs#L152 我意识到我可以通过添加一个名为 DOTNET_ADD_GLOBAL_TOOLS_TO_PATH 且值为 false 的新应用程序设置来解决此问题

Application setting

之后我可以像以前一样使用 kudu 部署我的应用程序。

【讨论】:

  • 哇,有了这些更改,它按预期工作了。谢谢!!
猜你喜欢
  • 2018-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-26
  • 2019-05-28
  • 2021-10-15
  • 1970-01-01
  • 2017-09-01
相关资源
最近更新 更多