I have common code which is require in other Azure functions, how can I share the common code among the Azure functions?
Asked
Active
Viewed 9,435 times
7
-
What language are you working with? If this is C#, this question is a duplicate of https://stackoverflow.com/questions/39540951/azure-functions-shared-classes/39541156#39541156 – Fabio Cavalcante May 30 '17 at 23:51
-
C#, Thanks I will try with this link – Furqan Misarwala Jun 10 '17 at 18:19
-
How can I add nuget references for shared code ? – Furqan Misarwala Jun 12 '17 at 11:55
2 Answers
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:

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.

rickvdbosch
- 14,105
- 2
- 40
- 53