Azure-functions-core-tools: System.ArgumentNullException running new Function project from Visual Studio

Created on 26 Jun 2019  路  14Comments  路  Source: Azure/azure-functions-core-tools

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 of AppSettingsFile via Json.NET.
  • Since it doesn't have any other constuctors, one with string filePath is used with null 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

investigate

Most helpful comment

i have this exception running rider

All 14 comments

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

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.

@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>

Reopening as there new data

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);
        }

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).

i have this exception running rider

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

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.

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

Having the same issue.

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

frozenbubble picture frozenbubble  路  4Comments

Mikey032 picture Mikey032  路  3Comments

dstaley picture dstaley  路  3Comments

SteveALee picture SteveALee  路  4Comments

AssassinTee picture AssassinTee  路  3Comments