Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

azure functions with nuget packages that have different versions of the same dependency

I am writing an Azure Function that is using 2 nuget packages (A and B) from my private feed. Package A uses Dapper version 1.50.2 directly and package B uses Dapper.SimpleCrud 1.13.0 which has a dependency on Dapper version [1.42.0, 2.0.0).

Within the Azure Function I have added project.json where I specify package A and B and their versions.

When I look at the installed packages within the azure function I see Dapper 1.42.0 and 1.50.2 are both installed. when I attempt to call methods in package A and B I get an error on the azure function logs saying that it could not find Dapper version 1.40. (depending on how I set my project.json it would be either Dapper 1.40 or 1.50 that is not found by Azure Function)

I have created a test version of the Dapper.SimpleCRUD package where the dependency on dapper is from [1.50.2, 2.0.0) and every thing works.

I have also tried to add Dapper 1.50.2 to project.json in the hopes that it will be used by Dapper.SimpleCRUD, but it still seems to pull in Dapper 1.42.

Is there some setting that I missing on Azure Functions to allow this setup to work or is this a limitation on Azure Function package management ?.

Thanks for any help you can provide.

like image 896
Nish Avatar asked Nov 26 '16 08:11

Nish


People also ask

Can a function app have multiple functions Azure?

Organize your functions As part of your solution, you likely develop and publish multiple functions. These functions are often combined into a single function app, but they can also run in separate function apps.

How can we use NuGet packages in my Azure functions?

Within Visual Studio, adding NuGet packages is easier; expand your dependencies, right-click and choose the option 'Manage NuGet Packages'. The NuGet Package dialogue will appear, and you can select any Nuget package you want to install for your Azure Function.

Are NuGet packages dependencies?

Any time a package is installed or reinstalled, which includes being installed as part of a restore process, NuGet also installs any additional packages on which that first package depends. Those immediate dependencies might then also have dependencies on their own, which can continue to an arbitrary depth.

Which version of the Azure functions runtime is required to host a function app in your own custom container?

By default, function apps created in the Azure portal and by the Azure CLI are set to version 4.


1 Answers

I seems like an issue (AFAIK even as late as Oct 2016) that they still haven't figured out a good way of doing binding redirects in azure function.

I ran into a similar issue with my azure function using two different nuget packages with same dependency (but different versions).

There was a similar question asked here : Azure Functions binding redirect

I ended up keeping the least possible number of nugets to avoid binding redirects. If this is not possible with your project try using for webjobs (atleast as a short term solution) till azure functions supports this.

like image 59
frictionlesspulley Avatar answered Oct 06 '22 13:10

frictionlesspulley