7

I have common code which is require in other Azure functions, how can I share the common code among the Azure functions?

TAbdiukov
  • 1,185
  • 3
  • 12
  • 25
Furqan Misarwala
  • 1,743
  • 6
  • 26
  • 53

2 Answers2

3

If the Functions you are wanting to share code between are under the same Function App you can do the following:

https://stackoverflow.com/a/39541156/2854993

And if they are separate Function Apps, I asked a similar question - see:

Azure Functions - Shared code across Function Apps

Chris
  • 3,113
  • 5
  • 24
  • 46
  • @furqanms https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp#using-nuget-packages – Chris Jun 13 '17 at 12:14
  • But my share code is outside of azure functions and it is inside wwwroot/shared/common.csx folder, so how can I give reference s into this share files and where the package will be defined for this share code in general? – Furqan Misarwala Jun 13 '17 at 12:52
  • @furqanms sorry I see what you mean. When I have done it previously, I have put the nuget dependencies in all of the project.json files of the functions which use the code in wwwroot/shared/common.csx - not sure if this is the correct approach but it seemed to work. – Chris Jun 13 '17 at 13:39
  • I am not sure is it work or not , looking for good approach , because I am working on enterprise application and need to implement it perfect and clear. Adding nuget to each functions is not good approach for me – Furqan Misarwala Jun 13 '17 at 14:04
  • @furqanms perhaps post a new question or update this one. I would be interested to know the proper answer myself. – Chris Jun 13 '17 at 14:06
  • @furqanms ask it here in a comment? https://stackoverflow.com/questions/36411536/how-can-i-use-nuget-packages-in-my-azure-functions – Chris Jun 13 '17 at 14:08
0

I managed to get shared code to work (or rather: compile) using an Azure Function Tools for Visual Studio project. In case of the screenshot, the shared library is actualy another Function project. I also tried to work with class libraries: those seem to work as well.

Haven't gotten around to deploying it yet, by the way. Running (and debugging) it localy is not an issue, so I guess deploying shouldn't be one either.

Shared library

rickvdbosch
  • 14,105
  • 2
  • 40
  • 53