Search code examples
c#.netazureazure-functionsazure-webjobs

Publish Azure Function as NuGet package (or load function from external assembly)


I'm looking into publishing a reusable Azure Function as a NuGet package, in order to easily consume it in other projects. This way I can reference the NuGet package in other projects. This way I could dynamically compose a set of Azure Functions to be deployed to an Azure Function service.

Is this currently possible? Or, can functions e.g. be defined in an external assembly, and be "picked up" by the Azure Function host?

I know this is possible with Azure WebJobs, but I haven't found a way to achieve the same result using Azure Functions.


Solution

  • Adding <FunctionsInDependencies>true</FunctionsInDependencies> in the .csproj file seems to do the trick.

    Do make sure you actually call the dependency somewhere in the code (e.g. in Startup.cs) to make sure the assembly isn't optimized away by the compiler.