或从外部程序集加载函数

或从外部程序集加载函数

本文介绍了将 Azure 函数发布为 NuGet 包(或从外部程序集加载函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将可重用的 Azure 函数作为 NuGet 包发布,以便在其他项目中轻松使用它.这样我可以在其他项目中引用 NuGet 包.通过这种方式,我可以动态组合一组 Azure Functions 以部署到 Azure Function 服务.

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.

目前可以吗?或者,可以发挥作用,例如在外部组件中定义,并被拾取";由 Azure Function 主机提供?

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

我知道这可以通过 Azure WebJobs 实现,但我还没有找到使用 Azure Functions 实现相同结果的方法.

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

推荐答案

.csproj 文件中添加 <FunctionsInDependencies>true</FunctionsInDependencies> 似乎可以做到把戏.

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

请确保您确实在代码中(例如在 Startup.cs 中)调用了依赖项somewhere,以确保编译器不会优化程序集.

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.

这篇关于将 Azure 函数发布为 NuGet 包(或从外部程序集加载函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:30