Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.91k stars 435 forks source link

Azure Functions V2 3.0.0-beta5 startup errors with service bus when bindings are not correct #2786

Open grahambunce opened 6 years ago

grahambunce commented 6 years ago

Investigative information

Local development environment Function App version: 3.0.0-beta5 .NET 4.7.1 needed to be installed to run the app

Repro steps

Provide the steps required to reproduce the problem:

  1. Create a clean .NET Functions C# console app (.NET Standard 2) (NB: Microsoft.NET.Sdk.Functions version is 1.0.13)
  2. Add Microsoft.Azure.WebJobs.ServiceBus (3.0.0-beta5)
  3. Change triggers to Service Bus Triggers
  4. Add additional config information - ensure the endpoint is incorrect
  5. Run app

Expected behavior

App to start without errors but to warn of missing bindings (i.e. topic name, subscription)

Actual behavior

Error messages in log:

No reference to potential misconfiguration - exception trace is therefore misleading

Java home covered by https://github.com/Azure/azure-functions-host/issues/2765 [Expected release date?]

Version of Microsoft.Azure.Amqp brought into solution file by Microsoft.Azure.ServiceBus is 2.1.1

Attempted redirect: "BindingRedirects": "[ { \"ShortName\": \"Microsoft.Azure.Amqp\", \"RedirectToVersion\": \"2.1.2\", \"PublicKeyToken\": \"31bf3856ad364e35\" }]"

No impact

[03/05/2018 09:15:50] Unable to configure java worker. Could not find JAVA_HOME app setting. [03/05/2018 09:15:50] [03/05/2018 09:15:50] Could not configure language worker Java. [03/05/2018 09:15:50] [03/05/2018 09:15:50] Loaded custom extension: ServiceBusExtensionConfig from 'referenced by: Method='MSS.PatronAccount.Host.CirculationEvent.Run', Parameter='myQueueItem'.' [03/05/2018 09:15:51] Generating 1 job function(s) [03/05/2018 09:15:51] Found the following functions: [03/05/2018 09:15:51] MSS.PatronAccount.Host.CirculationEvent.Run [03/05/2018 09:15:51] [03/05/2018 09:15:51] Host initialized (1091ms) Listening on http://localhost:7071/ Hit CTRL-C to exit... [03/05/2018 09:15:53] Host started (2939ms) [03/05/2018 09:15:53] Job host started [03/05/2018 09:15:54] Host lock lease acquired by instance ID '0000000000000000000000009462CA7D'. [03/05/2018 09:15:54] Exception during runtime resolution of assembly 'Microsoft.Azure.Amqp.resources, Version=2.1.0.0, Culture=en-GB, PublicKeyToken=31bf3856ad364e35': 'System.InvalidCastException: [A]System.AppDomain cannot be cast to [B]System.AppDomain. Type A originates from 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.6\System.Private.CoreLib.dll'. Type B originates from 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.6\System.Runtime.Extensions.dll'. [03/05/2018 09:15:54] at Microsoft.Azure.WebJobs.Script.Description.FunctionAssemblyLoader.ResolveAssembly(Object sender, ResolveEventArgs args) in C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\FunctionAssemblyLoader.cs:line 66' [03/05/2018 09:15:54] Unable to find assembly 'Microsoft.Azure.Amqp.resources, Version=2.1.0.0, Culture=en-GB, PublicKeyToken=31bf3856ad364e35'. Are you missing a private assembly file? [03/05/2018 09:15:54] Exception during runtime resolution of assembly 'Microsoft.Azure.Amqp.resources, Version=2.1.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35': 'System.InvalidCastException: [A]System.AppDomain cannot be cast to [B]System.AppDomain. Type A originates from 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.6\System.Private.CoreLib.dll'. Type B originates from 'System.Runtime.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' in the context 'Default' at location 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.6\System.Runtime.Extensions.dll'. [03/05/2018 09:15:54] at Microsoft.Azure.WebJobs.Script.Description.FunctionAssemblyLoader.ResolveAssembly(Object sender, ResolveEventArgs args) in C:\azure-webjobs-sdk-script\src\WebJobs.Script\Description\DotNet\FunctionAssemblyLoader.cs:line 66' [03/05/2018 09:15:54] Unable to find assembly 'Microsoft.Azure.Amqp.resources, Version=2.1.0.0, Culture=en, PublicKeyToken=31bf3856ad364e35'. Are you missing a private assembly file?

Related information

Source ```csharp public static class CirculationEvent { [FunctionName("CirculationEvent")] public static void Run([ServiceBusTrigger("circulation", "account", Connection = "microsoft.servicebus.connectionstring")]string myQueueItem, TraceWriter log) { log.Info($"C# Queue trigger function processed: {myQueueItem}"); } } ```
pragnagopa commented 6 years ago

Fix for https://github.com/Azure/azure-functions-host/issues/2765 will be part of next release. Approximate ETA within in two weeks.

cc: @fabiocav for assembly loading issue. @fabiocav - would the latest changes resolve assembly loading issue here?

fabiocav commented 6 years ago

The latest changes (yet to be released with updated tooling) will help with these issues.

grahamehorner commented 6 years ago

@fabiocav is it possible to get everything from the repo/build and deploy to a instance of VS2017 to allow us to continue development, until such time these changes are made public? or is there a nightly build myget feed available

Bubeee commented 6 years ago

Hello.

Have the same issue. Thought, it was caused by Microsoft.Azure.KeyVault package installing. But it worked fine last week (have a couple of ServiceBusTrigger functions).

image

My nuget dependencies:

image

PS. Using the latest tools and VS 2017 updates.

Regards, Uladzimir.

grahamehorner commented 6 years ago

I'm also getting this issue when binding are correct, and the Function is working under load ? and also when using EvenHubTrigger & EventHub bindings ? this may be related to some other change, however the same error is presented in regards to the Microsoft.Azure.Amqp.resources

Bubeee commented 6 years ago

@grahambunce hi, yesterday I've attempted to reproduce your steps on the newly-created functions project - but it was working fine. So the problem is definitely in something else.

Bubeee commented 6 years ago

Seems like my issue was with the wrong specification of topic name. If it taken from the app settings, it should be rounded with %

Dummy. Lost quite a lot of time on this. Cause in some other trigger % symbols should be omitted, I decided to skip it here to. Terrible mistake :)

image

grahambunce commented 6 years ago

@Bubeee @grahamehorner I think this is representative of the same problem that caught me out... if there is something set up wrong the process crashes with an error (unable to find assembly) that bears no relation to what the problem actually is, so when you hit it, you're left randomly trying things in the hope you stumble across what the issue actually is.

Will this be sorted out in the next beta package?