Azure / Azure/azure-functions-host

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

Open
#2,786 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 12h
Merged PRs (30d)
38

Description

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

- Unable to configure java worker. Could not find JAVA_HOME app setting
- Exception during runtime resolution of assembly 'Microsoft.Azure.Amqp.resources Version=2.1.0.0

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

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the stated .NET Standard 2 C# console app, Microsoft.NET.Sdk.Functions 1.0.13, and ServiceBus 3.0.0-beta5 configuration. Start at WebJobs.Script/Description/DotNet/FunctionAssemblyLoader.cs line 66 and compare the logged assembly-resolution failure with the incorrect binding setup. Done means invalid Service Bus bindings produce a clear missing-binding warning rather than misleading assembly or Java-worker errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.