Open Kryptos-FR opened 9 months ago
Thanks for opening this. Let me provide some information on the two issues you've flagged.
This is a known issue and being addressed with SDK updates actively being worked on. This is currently in PR (#1946) and tracked by #1863 . The workaround at the moment, in addition to what you've done, is to define a global Nuget.config, but this fix will be released soon.
To provide some clarity, this is not an issue with transitive dependencies not being pulled in. This is an in-proc limitation, not a .NET Isolated issue.
The extensions build output is what the host runs (which is what generates the message you've shared), and the host does not support extensions using .NET 8 dependencies. When writing WebJobs custom bindings for Functions, this limitation needs to be observed and will apply to your in-proc applications as well. Your worker extensions do not have this limitation, and you're free to use any target there.
The project has the correct set of dependencies, but those restricted assemblies (provided by the host/runtime environment) are automatically removed at build time as they are unified at runtime. If you inspect the build output of your in-proc application, you'll notice that this assembly, unless explicitly preserved, will be removed there as well.
Issue 1: Valid, fix in progress. Tracked by #1863 . Some workarounds available. Issue 2: A limitation of WebJobs extensions for Functions and consistent with the in-proc experience.
I want to better understand your statement about the Isolated model quality. Are there other issues also impacting your experiences?
@fabiocav Thanks for replying. I don't understand your second point about .NET 8 dependencies, though. Microsoft.Extensions.Logging.Abstractions/8.0.0
is supposed to work for both .NET 6 and .NET 8 (at least according to the nuget package).
In fact I have the exact same loading error when all projects target .NET 6 (including the final worker project). In my previous message, all other libraries (esp. the custom binding) were also only targeting .NET 6. I changed the target for the worker to also be .NET 6 and the same error appears.
However, if I downgrade to use Microsoft.Extensions.Logging.Abstractions/6.0.0
instead, the error is gone.
Looking deeper into what are the difference between the two package versions, it appears that version 6.0 doesn't have a .targets file in the buildTransitive
folder (or more specifically it has the special _._
one). However, the 8.0 version has one for .net 6 specifically. Could that be the issue?
In addition, all the points you mentioned (esp. about this "When writing WebJobs custom bindings for Functions, this limitation needs to be observed and will apply to your in-proc applications as well") is documented nowhere. How are we suppose to get that?
In general, there is almost zero documentation on how the isolated process work, the architecture between the host process and the worker process, or how to write custom bindings that work for both models. I had to use classes that are all marked as obsolete with the message "Not ready for public consumption.". This includes FluentBindingRule<TAttribute>
(used by BindToInput()
, BindingFactory.GetTriggerBinding()
and the related ITriggerBindingStrategy<TMessage, TTriggerValue>
. That is not a great developer experience, when you have no idea if you are using the right code or if that code will still be valid in a subsequent release because everything was marked as "not-ready".
I commented on #2092 by linking to a repository illustrating some usage. I guess it can also be linked here as it demonstrates the nuget.config
issue as well.
https://github.com/Kryptos-FR/azure-functions-dotnet-worker-2092
Hello, any update ? (as well as #2092)
Some update would definitely be appreciated!
Summary
We are trying to make a custom binding that can use
Google.Cloud.PubSub.V1
. As part of the dependencies we are also referencingMicrosoft.Extensions.Logging.Abstractions
. However this fails at runtime with the following error:We have a couple of issues. For some of them, no workaround was found. The conclusion is that the isolated-process model is not even in beta and certainly not ready for production, despite Microsoft pushing for using it instead of the in-process model.
Nuget.config
We build our packages into a local Azure DevOps repository. To be able to restore properly we have added that source in a
nuget.config
file, such as:Custom binding solution
Our custom binding is implemented in 3 projects in order to be used for both the in-process and the isolated-process execution models. We have:
CustomBinding.GooglePubSub.Core
This project implements the main controller that can communicate with Google PubSub. That project is supposed to be agnostic of the execution model. It has the following dependencies:
CustomBinding.GooglePubSub
This project implements the in-process (web job) version. It has the following dependencies:
CustomBinding.GooglePubSub.Isolated
And finally, the project for the isolated process has these dependencies:
In addition, it "loads" the dependencies thanks to the
ExtensionInformation
attribute:First issue: nuget.config is not followed
When building the consuming project, the build of the worker fails because it cannot find the package that is indirectly referenced thanks to the
ExtensionInformation
attribute. And this, despite having a correctnuget.config
at the root directory. It seems that because it is built in a temp folder it doesn't bring along the content of thenuget.config
file. That is the first issue that needs to be fixed by your team.Workaround
We found a workaround for that particular issue. We add this to the consuming project in order to pretend to have a dependency so that it get restored first and find itself into the build maching
.nuget
cache.Looking at the generated .csproj (in the Temp folder) during the build, we can inspect the
project.assets.json
file. And in there we, see that indeed theconfigFilePaths
value is wrong as it is using the globalnuget.config
of the machine instead of our custom one.Second issue: transitive package dependencies are not respected
We believe the reason for the runtime crash is because the generated worker project doesn't have the right packages dependencies. While the generated
.csproj
looks fine:When looking into the
project.assets.json
we can see that the right dependencies are supposed to be resolved.Yet, when we go back to the
bin
folder of the consuming project, we don't seeMicrosoft.Extensions.Logging.Abstractions.dll
present under thebin\Debug\net8.0\.azurefunctions
, and because of that it fails at runtime.Workaround
We try explicitly referencing
Microsoft.Extensions.Logging.Abstractions
version8.0.0
in all projects involved. Yet, it doesn't solve anything. So there is currently no workaround.