0

I'm using Azure functions 1.x runtime and using .net framework 4.6.2 In my solution , I've two projects

1) Function App project 2) Class library targeting 4.6.2 framework. It has all the code for my business logic. This class library has other dependencies which are added by nuget

The function app project reference the class library via project reference in the solution.

When I build the project everything gets compiled without any error and under the bin folder of my function app project, I can see the Business Logic library dll as well as its dependencies

But when I run the project , it gives me the error of "Could not load assembly". This assembly is referring to the transitive dependency of my business logic library which were added via nuget.

I've compared the version and everything and under the bin folder of my function app project I can see all the required dependencies then why the functions runtime is not able to load this files. Am i doing some thing wrong

Please advise.

MAQ
  • 443
  • 7
  • 15

1 Answers1

0

Workaround can be to have class library project for your functions, instead of function app project.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library

We did it this way without problems with dependency versions e.g. Newtonsoft

The cons is that you can't debug your function locally in VS. But if you have unit tests it is not so painful.

wolszakp
  • 1,109
  • 11
  • 25
  • Doesn't the function app project template itself is the class library ? – MAQ May 10 '18 at 06:40
  • Indeed. However build for it is different. Look at the bin folder structure. In past I got project as class library copy bin output and configure json - without any problem with dependencies. Right now I am using function project and need to solve dependencies issues. That's why i would call it workaround :) – wolszakp May 10 '18 at 10:39
  • This class library can be in the same solution as the function app project or must be on a different solution (and create a nuget package of the class library and import the package into the function app project) – joacoleza May 23 '18 at 16:15