Open brandonh-msft opened 6 years ago
I forked @lindydonna's SlackBinding repo, added v2 binding and functions projects to it, and reproduced the error. The v1 portions of her repo do not error out at all. This, also, was curious to me since in the Wiki we say the following:
To author a custom binding for Azure Functions, you must use the 2.0 runtime. See Azure Functions 2.0 support.
¯\_(ツ)_/¯
=
) to specific versions of dependencies, especially Newtonsoft.JSONOk I got this working but boy did it require some sleuthing & hacking. It really shows the issues we've got today with our nuget packages...
Bottom line, you can't use a .Net Standard implementation of a Binding across both Functions v1 and Functions v2 (:sad panda:)
The issues show up when you look at the dependencies for Microsoft.NET.Sdk.Functions
(v1.0.9) and see this:
Where across NetFX and NetCore we're not only referencing different versions of the same packages, but locking to versions (=
vs >=
). Then, when you create a new .Net Standard lib, and use Type Resolution to automatically pull in Microsoft.Azure.Webjobs
for the types needed to create a binding, you get the stable versions which means v2.1.0 and its dependencies which look like:
So now you've got a mismatch on Webjobs & Webjobs.Core between your Function app and the Binding library.
If you manually bump your Webjobs SDK version to the 3.0.0-beta4 used by the .Net Standard Functions SDK, you'll be good for a .Net Standard-based binding. However, that won't work for your NetFX-based binding, because it needs Webjobs 2.1.0 locked (nothing greater) so you'll have to make a separate lib for your NetFX binding for the sole purpose of having the right references - nothing else.
To boot, after you solve this problem, you're left dealing with the issue of the Host vs the Nupkg and have to do the project gymnastics outlined here.
@brandonh-msft since you got things working, would it make sense to move your observations on nuget versions into a separate issue, since this one is about creating and using a custom binding?
Following SDK's versions are compatible with each other: Microsoft.Azure.WebJobs (2.1.0) Microsoft.NET.Sdk.Functions (1.0.11) Newtonsoft.Json (9.0.1)
I would recommend folks use the more recent versions:
Microsoft.Azure.WebJobs (2.2.0) Microsoft.NET.Sdk.Functions (1.0.21) Newtonsoft.Json (9.0.1)
I just experienced this also with
<PackageReference Include="Microsoft.Azure.WebJobs.ServiceBus" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.26" />
I had to use Webjobs.ServiceBus 2.2.0
to resolve it.
The strange this is in some projects the above combination does work..
I've created a local custom binding in a separate .Net Standard 2.0 assembly. This binding exposes & implements all the necessary types & interfaces. However, when I build my Functions v2 project which uses the binding in the Function signature (via an Attribute), the build system errors out with a FileNotFoundException which doesn't make sense. If I remove merely the usage of the binding (not the reference to its containing lib), build works fine
Repro steps
Provide the steps required to reproduce the problem
Function1
classExpected behavior
The custom binding and consuming Function build successfully and my binding is used by the Function.
Actual behavior
The build system errors out with the following message:
Known workarounds
None
Related information