Nuget reference not found during LogicApp runtime

Michael Ribeiro 25 Reputation points
2024-08-22T14:26:36.1+00:00

We have created an Azure function which is referencing a 3rd party FTP client (Rebex.Ftp). This function is called locally from a LogicApp workflow. We debug it locally (the function) and everything works as expected. The issue becomes when we deploy the logic app and run the workflow we get the following error:

[Error] Function 'FTPConnector', Invocation id '24b32513-9aa1-4e88-ad1d-a4ed38d6f7fd': An exception was thrown by the invocation.

Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: Function 'FTPConnector', Invocation id '24b32513-9aa1-4e88-ad1d-a4ed38d6f7fd': An exception was thrown by the invocation.

Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Rebex.Ftp, Version=7.0.8943.0, Culture=neutral, PublicKeyToken=1c4638788972655d'. The system cannot find the file specified. File name: 'Rebex.Ftp, Version=7.0.8943.0, Culture=neutral, PublicKeyToken=1c4638788972655d'

at lambda_method1(Closure, FTPConnector, Object[])

at Microsoft.Azure.Functions.Worker.Invocation.TaskMethodInvoker`2.InvokeAsync(TReflected instance, Object[] arguments) in D:\a_work\1\s\src\DotNetWorker.Core\Invocation\TaskMethodInvoker.cs:line 23

at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionInvoker`2.InvokeAsync(Object instance, Object[] arguments) in D:\a_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionInvoker.cs:line 31

at Microsoft.Azure.Functions.Worker.Invocation.DefaultFunctionExecutor.ExecuteAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\Invocation\DefaultFunctionExecutor.cs:line 49

at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13

at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 77

at Microsoft.Azure.Functions.Worker.Handlers.InvocationHandler.InvokeAsync(InvocationRequest request) in D:\a_work\1\s\src\DotNetWorker.Grpc\Handlers\InvocationHandler.cs:line 88

During deployment we are restoring Nuget packages and I have double checked that the assemblies are copied to lib\custom\net8 logicapp folder

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,092 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,203 questions
0 comments No comments
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 15,886 Reputation points Microsoft Employee
    2024-08-22T21:37:43.1366667+00:00

    Hi @Michael Ribeiro Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    Looking at the error stack, the error message seems to be originating from the Azure function. If you have deployed the function app on to Azure, you need to make sure you have provided a reference to the dependent packages. Starting with function app version 2.x+, you can refer the needed dependencies to the Function App by defining them in a file named function.json The core tools build .csproj file to install the required libraries. Here is an example of an extensions.csproj file that adds a reference of external library to the Function App.

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <TargetFramework>netstandard2.0</TargetFramework>
        </PropertyGroup>
        <ItemGroup>
            <PackageReference Include="Microsoft.ProjectOxford.Face" Version="1.1.0" />
        </ItemGroup>
    </Project>
    
    
    

    Please refer the documentation Using Nuget packages for more information.

    Please also find a similar solution shared on the thread on how to use an SFTP client in Function app.

    Hope this helps! If you run into any additional issues after trying the above steps, please reach out to us and we would be glad to assist you further.

    Update

    Changing the framework to 4.7.2 and then referencing Rebex.Ftp assembly worked. Using the external libraries with .Net 8.0 continues to produce this error


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Michael Ribeiro 25 Reputation points
    2024-08-23T17:35:57.2533333+00:00

    Hi LeelaRajeshSayana-MSFT,

    Thank you for your reply. I have the reference to the package in the corresponding .csproj file:
    User's image It's curious that if I have the project running under .net472, I have no issue and it works. It seems with .net8 it doesn't

    0 comments No comments

  2. Pinaki Ghatak 4,610 Reputation points Microsoft Employee
    2024-08-26T08:24:48.8233333+00:00

    Hello @Michael Ribeiro

    It seems like the FTPConnector function is unable to load the Rebex.Ftp assembly.

    This could be due to a missing or incorrect reference to the assembly.

    To resolve this issue, you can try the following steps:

    1. Ensure that the Rebex.Ftp assembly is included in the project references and is set to "Copy Local" = true.
    2. Check the function's project file to ensure that the Rebex.Ftp assembly is included in the output folder. You can do this by opening the project file and looking for the following line:

    PreserveNewest

    1. Check the function's host.json file to ensure that the assembly is being loaded correctly. You can do this by opening the host.json file and looking for the following line:
    { "functions": [ { "assemblyName": "Rebex.Ftp" } ] }
    
    1. If the above steps do not resolve the issue, you can try manually copying the Rebex.Ftp assembly to the bin folder of the function app on Azure. You can do this by using Kudu or FTP to access the function app's file system and copying the assembly to the bin folder.

    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.