Sharing code between functions

In a C# script-based Function App, adding a new file to one of the functions will not make it available to other functions in the application.

To share code between functions, we will need to do the following two things:

  • Create a folder named Shared at the root level of a Function App, and add shared code files to this folder. The WebJobs SDK (that Azure Functions are based on) watches for any code changes in the Shared folder and makes sure that the changes are picked up by the functions.
  • Create #load directives to the specific location of the shared files in each function that references the shared code.
You can add other folders to the function's watch list by modifying the watchDirectories setting of the ...

Get Serverless computing in Azure with .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.