azure-functions-core-tools: System.ArgumentNullException running new Function project from Visual Studio
Created fresh Azure Functions project from VS 2019 with storage in Azure. Trying to start it gives the following error: System.ArgumentNullException: 'Value cannot be null. Parameter name: path'
at
System.IO.FileSystem.dll!System.IO.File.ReadAllText(string path) Unknown
System.IO.Abstractions.dll!System.IO.Abstractions.FileWrapper.ReadAllText(string path) Unknown
func.dll!Azure.Functions.Cli.Common.FileSystemHelpers.ReadAllTextFromFile(string path) Line 33 C#
func.dll!Azure.Functions.Cli.Common.AppSettingsFile.AppSettingsFile(string filePath) Line 18 C#
[Lightweight Function]
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.Serialization.ObjectConstructor<object> creator, string id) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, Newtonsoft.Json.Serialization.JsonProperty containerProperty, string id, out bool createdFromNonDefaultCreator) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, object existingValue) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, object existingValue) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Newtonsoft.Json.JsonReader reader, System.Type objectType, bool checkAdditionalContent) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.JsonSerializer.DeserializeInternal(Newtonsoft.Json.JsonReader reader, System.Type objectType) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.JsonConvert.DeserializeObject(string value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) Unknown
Newtonsoft.Json.dll!Newtonsoft.Json.JsonConvert.DeserializeObject<Azure.Functions.Cli.Common.AppSettingsFile>(string value, Newtonsoft.Json.JsonSerializerSettings settings) Unknown
func.dll!Azure.Functions.Cli.Common.AppSettingsFile.AppSettingsFile(string filePath) Line 18 C#
func.dll!Azure.Functions.Cli.Common.SecretsManager.GetSecrets() Line 42 C#
func.dll!Azure.Functions.Cli.Helpers.WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(Azure.Functions.Cli.Interfaces.ISecretsManager secretsManager) Line 134 C#
func.dll!Azure.Functions.Cli.Helpers.GlobalCoreToolsSettings.Init(Azure.Functions.Cli.Interfaces.ISecretsManager secretsManager, string[] args) Line 48 C#
func.dll!Azure.Functions.Cli.ConsoleApp.ConsoleApp(string[] args, System.Reflection.Assembly assembly, Autofac.IContainer container) Line 173 C#
func.dll!Azure.Functions.Cli.ConsoleApp.RunAsync<Azure.Functions.Cli.Program>(string[] args, Autofac.IContainer container) Line 38 C#
func.dll!Azure.Functions.Cli.ConsoleApp.Run.AnonymousMethod__0() Line 32 C#
System.Private.CoreLib.dll!System.Threading.Tasks.Task<System.Threading.Tasks.Task>.InnerInvoke() Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task..cctor.AnonymousMethod__278_1(object obj) Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.ExecuteEntryUnsafe() Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Unknown
System.Private.CoreLib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown
System.Private.CoreLib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() Unknown
Checking the source code I see that problem is as following:
AppSettingsFile
constructor tries to deserialize another instance ofAppSettingsFile
via Json.NET.- Since it doesn’t have any other constuctors, one with
string filePath
is used withnull
as parameter value. null
passed gives error above during recursive deserialization attempt.
It seems that adding empty private constructor to AppSettingsFile
should solve this, or there’s something wrong with my installation.
CLI v2.24.0 VS 2019 v16.2.0 Preview 3.0
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 23 (3 by maintainers)
I had this issue, and just clicked continue everytime an exception was being highlighted, eventually it got to the point where the function was running, even though these exceptions were happening.
I had “Common Language Runtime Exceptions” ticked in my Exception Settings. After unticking that, the exceptions were not caught and the function ran fine.
i have this exception running rider
I had to enable Just My Code setting in the Debug settings to fix this issue. (VS2022)
Having this exact issue in Rider 2022.3.1, when starting func in debug and running C:\Users\pavel\AppData\Local\AzureFunctionsTools\Releases\4.30.0\cli_x64 … surprisingly VS.net 2022 runs ok… Any ideas?
This helps… https://stackoverflow.com/questions/56716159/does-rider-has-the-just-my-code-debugging-option
I can also confirm I’m seeing this exact same behavior while trying to debug a Function in the latest version of Rider.
Same issue. VS 2019 16.8.2. Core Tools Version: 3.0.2996 Commit hash: c54cdc36323e9543ba11fb61dd107616e9022bba Function Runtime Version: 3.0.14916.0
Having the same issue.
Having the same issue. The project uses a secrets.json and a custom startup class that loads the secrets.json file.
https://github.com/Azure/azure-functions-core-tools/blob/5afacc827c2848e4debc23bb96604f1ffce09cc7/src/Azure.Functions.Cli/Common/AppSettingsFile.cs#L16-L34
https://github.com/Azure/azure-functions-core-tools/blob/5afacc827c2848e4debc23bb96604f1ffce09cc7/src/Azure.Functions.Cli/Common/AppSettingsFile.cs#L22
Bug while DeserializeObject<AppSettingsFile> but AppSettingsFile not had a parameterless constructor.