title: Getting UnauthorizedAccessException when deploying asp.net core app using Kudu build service
body: <p>I have set up Continuous Deployment of my aspnet core 2.2 app using Kudu build service (directly connected through GitHub). It was fine until the day before yesterday but started getting <code>UnauthorizedAccessException</code> when I try to deploy anything since yesterday. Nothing changed in my application though. Any idea what could be wrong here??</p>
  
  <p>Here is the detail exception:</p>
  
  <pre class="lang-cs prettyprint-override"><code>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"
  </code></pre>