azure-functions-host: Cannot add 'function.proj' file/nuget packages to azure-functions

I need to add some nuget packages to the azure function. While trying to add a ‘function.proj’ file, getting an error as follows,

2019-07-12T07:52:13.177 [Information] System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
2019-07-12T07:52:13.177 [Information] at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
2019-07-12T07:52:13.903 [Information] at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind)
2019-07-12T07:52:13.904 [Information] at System.Environment.SetEnvironmentVariableCore(String variable, String value, EnvironmentVariableTarget target)
2019-07-12T07:52:13.904 [Information] at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
2019-07-12T07:52:13.905 [Information] at Internal.Runtime.Augments.EnvironmentAugments.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
2019-07-12T07:52:13.905 [Information] at System.Environment.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
2019-07-12T07:52:13.905 [Information] at Microsoft.DotNet.Cli.Utils.EnvironmentProvider.SetEnvironmentVariable(String variable, String value, EnvironmentVariableTarget target)
2019-07-12T07:52:13.906 [Information] at Microsoft.DotNet.ShellShim.WindowsEnvironmentPath.AddPackageExecutablePathToUserPath()
2019-07-12T07:52:13.906 [Information] at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
2019-07-12T07:52:13.906 [Information] at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel, IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel, IAspNetCertificateSentinel aspNetCertificateSentinel, IFileSentinel toolPathSentinel, Boolean hasSuperUserAccess, DotnetFirstRunConfiguration dotnetFirstRunConfiguration, IEnvironmentProvider environmentProvider)
2019-07-12T07:52:13.907 [Information] at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
2019-07-12T07:52:13.907 [Information] at Microsoft.DotNet.Cli.Program.Main(String[] args)

Investigative information

  • Timestamp: 2019-07-12T07:52:48.560
  • Function App version : 2.0
  • Invocation ID: 0a370ad8-efcc-4e9a-8463-3041941b2877
  • Region: West US
  • Programming Language used: C#

Repro steps

Try to create a ‘function.proj’ file and add some nuget packages to it.

Expected behavior

After adding the above, nuget packages should get installed and show compilation succeeded message in the log.

Actual behavior

Throwing a “System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.” exception in the log.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

While we work on a permanent fix, a known mitigation is to set the following app setting in your Function App:

Name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE Value: 1

Again, apologies for the issue. We’ll have a permanent fix in place as soon as possible.

@mhoeger - Yes, It’s a V2 app. Issue is resolved, Thanks a lot 😊

Fix has been checked-in and is being deployed as part of this release https://github.com/Azure/app-service-announcements/issues/188

Please use https://github.com/Azure/app-service-announcements-discussions/issues/105 for discussions related to the release.

@abinayasekar93 I was able to solve this by, instead of writing the Azure function in the portal directly, creating it in Visual Studio, adding the NuGet package like any usual local project and publishing the function to Azure.