Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.28k stars 425 forks source link

System.ArgumentNullException running new Function project from Visual Studio #1409

Open alexb5dh opened 5 years ago

alexb5dh commented 5 years ago

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:

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

ahmedelnably commented 5 years ago

@alexb5dh this doesn't look like a known issue, can you please provide a repro so we can investigate more

ghost commented 5 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

worldspawn commented 4 years ago

@ahmedelnably can you reopen this. I'm getting the exact same exception with the exact same stack.

    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#

At this point this (the AppSettingsFile) has private variable _filePath of null and it then tried to read the contents of null.

    [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#

In the above frame we have an instance of AppSettingsFile which does not have a null _filePath. its pointing a file that exists (C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\bin\Debug\netcoreapp2.1\local.settings.json).

This is a different instance of AppSettingsFile than the top frame (different hashcode).

    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

I get this when I run in debug and break on ALL Common Language Runtime Exceptions. If i disable breaking I get this in my output:

.NET Setting WEBSITE_HOSTNAME = localhost:7071
.NET Setting AzureWebJobsScriptRoot = C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\bin\Debug\netcoreapp2.1
.NET Setting AZURE_FUNCTIONS_ENVIRONMENT = Development
[29/07/2019 6:11:34 AM] Building host: startup suppressed:False, configuration suppressed: False
Value cannot be null.
Parameter name: provider
Press any to continue....[29/07/2019 6:11:36 AM] Building host: startup suppressed:False, configuration suppressed: False
Hosting environment: Production
Content root path: C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\bin\Debug\netcoreapp2.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[29/07/2019 6:11:38 AM] Building host: startup suppressed:False, configuration suppressed: False
[29/07/2019 6:11:46 AM] Building host: startup suppressed:False, configuration suppressed: False
[29/07/2019 6:11:55 AM] Building host: startup suppressed:False, configuration suppressed: False
[29/07/2019 6:12:11 AM] Building host: startup suppressed:False, configuration suppressed: False

The host never starts and sits there indefinitely. I get the same behaviour if i run without debugging.

Now if I go to the cli and try it... Firstly (get-command func).source -> C:\Users\SamCritchley\AppData\Local\Yarn\bin\func.cmd

`Azure Functions Core Tools (2.7.1373 Commit hash: cd9bfca26f9c7fe06ce245f5bf69bc6486a685dd)

Now I run func start (on windows)

Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 51.29 ms for C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\SourceFileProcessing.csproj.
  SourceFileProcessing -> C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\bin\output\bin\SourceFileProcessing.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.39

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.7.1373 Commit hash: cd9bfca26f9c7fe06ce245f5bf69bc6486a685dd)
Function Runtime Version: 2.0.12507.0
[29/07/2019 6:16:00 AM] Starting Rpc Initialization Service.
[29/07/2019 6:16:00 AM] Initializing RpcServer
[29/07/2019 6:16:00 AM] Building host: startup suppressed:False, configuration suppressed: False
[29/07/2019 6:16:01 AM] Workers Directory set to: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers
[29/07/2019 6:16:01 AM] Found worker config: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\java\worker.config.json
[29/07/2019 6:16:01 AM] Will load worker provider for language: java
[29/07/2019 6:16:01 AM] Found worker config: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\node\worker.config.json
[29/07/2019 6:16:01 AM] Will load worker provider for language: node
[29/07/2019 6:16:01 AM] Found worker config: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\powershell\worker.config.json
[29/07/2019 6:16:01 AM] Will load worker provider for language: powershell
[29/07/2019 6:16:01 AM] Found worker config: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\python\worker.config.json
[29/07/2019 6:16:01 AM] Will load worker provider for language: python
[29/07/2019 6:16:01 AM] Worker path for language worker java: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\java
[29/07/2019 6:16:01 AM] Worker path for language worker node: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\node
[29/07/2019 6:16:01 AM] Worker path for language worker powershell: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\powershell
[29/07/2019 6:16:01 AM] Worker path for language worker python: C:\Users\SamCritchley\AppData\Local\Yarn\Data\global\node_modules\azure-functions-core-tools\bin\workers\python
[29/07/2019 6:16:02 AM] Initializing extension with the following settings: Initializing extension with the following settings:
[29/07/2019 6:16:02 AM] AzureStorageConnectionStringName: , MaxConcurrentActivityFunctions: 1, MaxConcurrentOrchestratorFunctions: 8, PartitionCount: 4, ControlQueueBatchSize: 16, ControlQueueVisibilityTimeout: 00:05:00, WorkItemQueueVisibilityTimeout: 00:05:00, FetchLargeMessagesAutomatically: True, ExtendedSessionsEnabled: False, EventGridTopicEndpoint: , NotificationUrl: http://localhost:7071/runtime/webhooks/durabletask, TrackingStoreConnectionStringName: , MaxQueuePollingInterval: 00:00:20, LogReplayEvents: False. InstanceId: . Function: . HubName: PdfHub. AppName: . SlotName: . ExtensionVersion: 1.8.3. SequenceNumber: 0.
[29/07/2019 6:16:02 AM] Initializing Host.
[29/07/2019 6:16:02 AM] Host initialization: ConsecutiveErrors=0, StartupCount=1
[29/07/2019 6:16:02 AM] Hosting starting
[29/07/2019 6:16:02 AM] LoggerFilterOptions
[29/07/2019 6:16:02 AM] {
[29/07/2019 6:16:02 AM]   "MinLevel": "None",
[29/07/2019 6:16:02 AM]   "Rules": [
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": null,
[29/07/2019 6:16:02 AM]       "CategoryName": null,
[29/07/2019 6:16:02 AM]       "LogLevel": null,
[29/07/2019 6:16:02 AM]       "Filter": "<AddFilter>b__0"
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": null,
[29/07/2019 6:16:02 AM]       "CategoryName": "Host.Results",
[29/07/2019 6:16:02 AM]       "LogLevel": "Error",
[29/07/2019 6:16:02 AM]       "Filter": null
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": null,
[29/07/2019 6:16:02 AM]       "CategoryName": "Host.Aggregator",
[29/07/2019 6:16:02 AM]       "LogLevel": "Trace",
[29/07/2019 6:16:02 AM]       "Filter": null
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": null,
[29/07/2019 6:16:02 AM]       "CategoryName": "Function",
[29/07/2019 6:16:02 AM]       "LogLevel": "Trace",
[29/07/2019 6:16:02 AM]       "Filter": null
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": null,
[29/07/2019 6:16:02 AM]       "CategoryName": null,
[29/07/2019 6:16:02 AM]       "LogLevel": "Debug",
[29/07/2019 6:16:02 AM]       "Filter": null
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[29/07/2019 6:16:02 AM]       "CategoryName": null,
[29/07/2019 6:16:02 AM]       "LogLevel": "None",
[29/07/2019 6:16:02 AM]       "Filter": null
[29/07/2019 6:16:02 AM]     },
[29/07/2019 6:16:02 AM]     {
[29/07/2019 6:16:02 AM]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[29/07/2019 6:16:02 AM]       "CategoryName": null,
[29/07/2019 6:16:02 AM]       "LogLevel": null,
[29/07/2019 6:16:02 AM]       "Filter": "<AddFilter>b__0"
[29/07/2019 6:16:02 AM]     }
[29/07/2019 6:16:02 AM]   ]
[29/07/2019 6:16:02 AM] }
[29/07/2019 6:16:02 AM] FunctionResultAggregatorOptions
[29/07/2019 6:16:02 AM] {
[29/07/2019 6:16:02 AM]   "BatchSize": 1000,
[29/07/2019 6:16:02 AM]   "FlushTimeout": "00:00:30",
[29/07/2019 6:16:02 AM]   "IsEnabled": true
[29/07/2019 6:16:02 AM] }
[29/07/2019 6:16:02 AM] SingletonOptions
[29/07/2019 6:16:02 AM] {
[29/07/2019 6:16:02 AM]   "LockPeriod": "00:00:15",
[29/07/2019 6:16:02 AM]   "ListenerLockPeriod": "00:00:15",
[29/07/2019 6:16:02 AM]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[29/07/2019 6:16:02 AM]   "LockAcquisitionPollingInterval": "00:00:05",
[29/07/2019 6:16:02 AM]   "ListenerLockRecoveryPollingInterval": "00:01:00"
[29/07/2019 6:16:02 AM] }
[29/07/2019 6:16:02 AM] ServiceBusOptions
[29/07/2019 6:16:02 AM] {
[29/07/2019 6:16:02 AM]   "PrefetchCount": 0,
[29/07/2019 6:16:02 AM]   "MessageHandlerOptions": {
[29/07/2019 6:16:02 AM]     "AutoComplete": true,
[29/07/2019 6:16:02 AM]     "MaxAutoRenewDuration": "00:05:00",
[29/07/2019 6:16:02 AM]     "MaxConcurrentCalls": 2
[29/07/2019 6:16:02 AM]   }
[29/07/2019 6:16:02 AM] }
[29/07/2019 6:16:02 AM] Starting JobHost
[29/07/2019 6:16:02 AM] Starting Host (HostId=samdesktop-1928642968, InstanceId=3aa548be-c84b-4756-89c3-0aa5bb147de3, Version=2.0.12507.0, ProcessId=37520, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
[29/07/2019 6:16:02 AM] Loading functions metadata
[29/07/2019 6:16:02 AM] 10 functions loaded
[29/07/2019 6:16:02 AM] Adding Function descriptor provider for language dotnet.
[29/07/2019 6:16:02 AM] Creating function descriptors.
[29/07/2019 6:16:02 AM] Function descriptors created.
[29/07/2019 6:16:02 AM] Generating 10 job function(s)
[29/07/2019 6:16:02 AM] Found the following functions:
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.BatchPdfSplitOrchestrator.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ExportImageOfPage.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.GetPdfInfo.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.PdfSplit.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessPdfCollateResults.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessPdfOrchestrator.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessPdfPageOrchestrator.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessSourceFileTrigger.Cancel
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessSourceFileTrigger.Run
[29/07/2019 6:16:02 AM] AzPdfTronDockerSpike.ProcessSourceFileOrchestrator.Run
[29/07/2019 6:16:02 AM] 
[29/07/2019 6:16:02 AM] Host initialized (207ms)
[29/07/2019 6:16:02 AM] Starting task hub worker. InstanceId: . Function: . HubName: PdfHub. AppName: . SlotName: . ExtensionVersion: 1.8.3. SequenceNumber: 1.
[29/07/2019 6:16:03 AM] Host started (976ms)
[29/07/2019 6:16:03 AM] Job host started
[29/07/2019 6:16:03 AM] Debug file watch initialized.
[29/07/2019 6:16:03 AM] Diagnostic file watch initialized.
[29/07/2019 6:16:03 AM] File event source initialized.
[29/07/2019 6:16:03 AM] Hosting started
Hosting environment: Production
Content root path: C:\Users\SamCritchley\source\az-pdftron-docker-spike\src\bin\output
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[29/07/2019 6:16:07 AM] FUNCTIONS_WORKER_RUNTIME=dotnet. Will shutdown all the worker channels that started in placeholder mode
[29/07/2019 6:16:08 AM] Host lock lease acquired by instance ID '0000000000000000000000000A054F81'.

In other words, it works!

In lieu of a repo...

host.json

{
  "version": "2.0",
  "logging": {
    "logLevel": {
      "default": "Debug",
      "Host.Results": "Error",
      "Function": "Trace",
      "Host.Aggregator": "Trace"
    }
  },
  "extensions": {
    "serviceBus": {
      "messageHandlerOptions": {
        "maxConcurrentCalls": 2
      }
    },
    "durableTask": {
      "hubName": "PdfHub",
      "controlQueueBatchSize": 16,
      "maxQueuePollingInterval": "00:00:20",
      "maxConcurrentActivityFunctions": 1,
      "maxConcurrentOrchestratorFunctions": 8
    }
  }
}

local.settings.json

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "REDACTED",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet",
        "ServiceBus": "REDACTED"
    }    
}

csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    <RootNamespace>SourceFileProcessing</RootNamespace>
    <IsDocker Condition=" '$(IsDocker)'=='' ">False</IsDocker>
    <AssemblyName>SourceFileProcessing</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>
  <ItemGroup Condition="'$(IsDocker)' == 'True'">
    <Content Include="..\lib\libPDFNetC.so" Link="bin\libPDFNetC.so">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.8.3" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.6" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
    <PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
  </ItemGroup>
  <ItemGroup Condition="'$(IsDocker)' == 'True'">
    <Reference Include="PDFNetDotNetCore">
      <HintPath>..\lib\PDFNetDotNetCore.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup Condition="'$(IsDocker)' == 'False'">
    <PackageReference Include="PDFTron.NETCore.Windows.x64" Version="6.11.0" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <Target Name="AfterBuild">
    <Copy SourceFiles="$(OutputPath)\PDFNETC.dll" DestinationFolder="$(OutputPath)\bin" ContinueOnError="false" />
  </Target>
</Project>
ahmedelnably commented 4 years ago

Reopening as there new data

worldspawn commented 4 years ago

Also I'm able to debug it via VS Code, takes some of the urgency out of it for me :)

Adding my startup code and a single trigger func from my code. Startup

using System;
using System.Threading.Tasks;
using AzPdfTronDockerSpike;
using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Table;

[assembly: WebJobsStartup(typeof(StartUp))]
namespace AzPdfTronDockerSpike
{
    // Implement IWebJobStartup interface.
    public class StartUp : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            var azureStorageConnectionString = Environment.GetEnvironmentVariable("AzureWebJobsStorage");
            var serviceBusConnectionString = Environment.GetEnvironmentVariable("ServiceBus");

            builder.Services.AddSingleton(p => CloudStorageAccount.Parse(azureStorageConnectionString));
            builder.Services.AddSingleton(p => p.GetService<CloudStorageAccount>().CreateCloudBlobClient());
            builder.Services.AddSingleton(p => p.GetService<CloudStorageAccount>().CreateCloudTableClient());
            builder.Services.AddSingleton(p => new Func<string, CloudBlobContainer>(name => p.GetService<CloudBlobClient>().GetContainerReference(name)));
            builder.Services.AddSingleton(p => new Func<Uri, Task<ICloudBlob>>(uri=> p.GetService<CloudBlobClient>().GetBlobReferenceFromServerAsync(uri)));
            builder.Services.AddSingleton(p => new Func<string, CloudTable>(name=> p.GetService<CloudTableClient>().GetTableReference(name)));
            builder.Services.AddSingleton(p => new Func<string, QueueClient>(name=> new QueueClient(serviceBusConnectionString, name)));
        }
    }
}
[FunctionName(Constants.FunctionNames.ProcessSourceFileTrigger)]
        [ServiceBusAccount("ServiceBus")]
        public async Task Run([ServiceBusTrigger("process-sourcefile")]string payload, [OrchestrationClient]DurableOrchestrationClient starter)
        {
            var request = JObject.Parse(payload);
            var fileUri = request.SelectToken("fileUri").Value<string>();
            var jobId = request.SelectToken("jobId").Value<string>();
            var fileId = request.SelectToken("fileId").Value<string>();
            var mimeType = request.SelectToken("mimeType").Value<string>();

            _logger.LogDebug("Process Pdf requested for blob {BlobUri}", fileUri);
            await starter.StartNewAsync(Constants.FunctionNames.ProcessPdfOrchestrator, Guid.NewGuid().ToString("N"), new {
                pageJobsToPerform = new [] { Constants.FunctionNames.ExportImageOfPage },
                fileUri,
                jobId,
                fileId,
                mimeType
            });
            _logger.LogDebug("Process Pdf request started with instance id {instanceId} for blob {BlobUri}", fileId, fileUri);
        }
Swiftless commented 4 years ago

I ran into this exact same issue running/debugging an Azure Function linked to an Azure Service Bus.

Switching to Microsoft Visual Studio 2019 Preview (v16.3.0 Preview 3.0 installed) appears to fix it. I note that I do need to also upgrade me preview version.

It is not working in Visual Studio 2019 (v16.2.5).

khuongntrd commented 4 years ago

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 but AppSettingsFile not had a parameterless constructor.

nickwinger commented 4 years ago

i have this exception running rider

BoutemineOualid commented 3 years ago

Having the same issue. The project uses a secrets.json and a custom startup class that loads the secrets.json file.

i3anaan commented 3 years ago

Experiencing the same issue. Me and a colleague both experience it, although on different projects, so it is not clear to us what is causing it.

JayVDZ commented 3 years ago

Also got this on VS 2019 16.7.5. It's intermittent. Sometimes reboots, clears, rebuilds work, sometimes not.

reynaerta commented 3 years ago

Having the same issue.

tbuha commented 3 years ago

Same issue. VS 2019 16.8.2. Core Tools Version: 3.0.2996 Commit hash: c54cdc36323e9543ba11fb61dd107616e9022bba Function Runtime Version: 3.0.14916.0

chris31389 commented 3 years ago

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.

ivyfae commented 2 years ago

I'm having this issue when trying to debug a functionapp in Rider 2021.3.3.

Running it using func host start works fine. Running using func host start --dotnet-isolated-debug and then selecting "Attach to Process" crashes dotnet. Idk if that's related or not.

$ func version
4.0.3971
$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.200
 Commit:    4c30de7899

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.6
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.200/

Host (useful for support):
  Version: 6.0.2
  Commit:  839cdfb0ec

.NET SDKs installed:
  6.0.200 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
mirekkukla commented 1 year ago

I believe the issue stems from the fact AppSettingsFile does not have a public parameterless constructor for use during Json deserialization. The exception occurs during this call in Azure.Functions.Cli.Common.AppSettingsFile:

AppSettingsFile appSettingsFile = JsonConvert.DeserializeObject<AppSettingsFile>(FileSystemHelpers.ReadAllTextFromFile(this._filePath));

Since the only available public constructor AppSettingsFile has is the one show below, the deserializer attempts the instantiate the AppSettingsFile object using this constructor with a null filePath. This in turn results in a recursive AppSettingsFile deserialization call, this time using the null filepath:

public AppSettingsFile(string filePath)
{
  this._filePath = filePath;
  try
  {
    // THIS RECURSIVE CALL IS WHERE THE EXCEPTION OCCURS
    AppSettingsFile appSettingsFile = JsonConvert.DeserializeObject<AppSettingsFile>(FileSystemHelpers.ReadAllTextFromFile(this._filePath));
    ....
  }
  catch
  {
     // ... set defaults here 
  }
}

This recurse deserialization call fails, as documented by this issue report. The catch block is used to instantiate a default AppSettingsFile object, which is then used to complete the outer deserialization attempt.

Adding a parameterless constructor that initializes values to their defaults should resolve the issue.

Rahkola commented 1 year ago

I can verify that this issue is still present, and I just run into it with VS2022 17.3.5 while running Azure Function with runtime v3. They symptoms were as described by OP, and I got the same call stack pointing to the issue in AppSettingsFile class. I couldn't see the process memory rising in diagnostic tools and eventually all output to the console stopped coming through and break points were not binding. It was as if the whole process just crashed when trying to run the function locally?

Eventually the fix for me was just closing and restarting Visual Studio, with no code changes whatsoever. After restart I can still observe the exceptions being throgh if I disabled 'Enable Just My Code' setting in Debugging -> General and enable all CLR exceptions - but break points started binding again, and I could run the function.

daveaglick commented 1 year ago

I can also confirm I'm seeing this exact same behavior while trying to debug a Function in the latest version of Rider.

BlooDCrescent commented 1 year ago

I had this exact problem with AppSettingsFile, so I deleted the whole solution containing functions project and checked out a fresh copy. After that, functions started with another error message (not throwing an exception this time) about not being able to connect to some local port and WebJobsDashboard unavailable (which was declared like "AzureWebJobsStorage": "UseDevelopmentStorage=true"), so I discovered that Azure Storage Emulator died. After restarting it the problem is gone.

jack0fshad0ws commented 1 year ago

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

TechWatching commented 1 year ago

Same issue here. Works fine in Visual Studio but not in Rider.

davyvanlaere commented 1 year ago

Just got this issue, havent pinpointed the issue, but in my case deleting the .vs folder fixes it.

EvgeniyaTaran commented 1 year ago

I had to enable Just My Code setting in the Debug settings to fix this issue. (VS2022)

andras-gyarmati commented 1 month ago

can someone just explain it to me why is this happening in rider? can i create an empty file somewhere just to quiet this error? it is very annoying to disable break on exception just to skip this issue and the enabling it every time im past this code

andras-gyarmati commented 1 month ago

I had to enable Just My Code setting in the Debug settings to fix this issue. (VS2022)

yh but it is very tedious to toggle this, as i need not just my code errors too