First, put your shared code inside a folder in the root of your Function App directory (e.g. "Shared"). Let's say I put a shared Message.csx
class in that folder (e.g. full path D:homesitewwwrootSharedMessage.csx
).
To include this into your function use the #load
command:
#load "..SharedMessage.csx"
using System;
using Microsoft.Azure.WebJobs.Host;
public static void Run(Message message, TraceWriter log)
{
log.Info($"C# Queue trigger function processed message: {message.Id}");
}
See the help page here for more information. By default, the files in that directory won't be tracked for changes. If you want to ensure that when files in that directory change your functions will pick up the changes and be recompiled, you can add your "Shared" directory to the watchDirectories
list in host.json
. E.g.:
{
"watchDirectories": [ "Shared" ]
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…