gpt4 book ai didi

Azure Functions : Can a shared . csx 使用 nuget 包?

转载 作者:行者123 更新时间:2023-12-03 03:06:01 24 4
gpt4 key购买 nike

如果 Azure 函数内的 .csx 文件在函数的 project.json 文件中列出,则该文件可以使用 nuget 包。例如:

{
"frameworks": {
"net46":{
"dependencies": {
"Microsoft.ProjectOxford.Face": "1.1.0"
}
}
}
}

但是放置在 Function App 根目录下(即不在特定函数中)的共享 .csx 文件会发生什么情况?有没有办法在应用程序功能(根)级别引入 nuget 包?

我找到了一种解决方法,可以将 nuget 包的 dll 上传到共享 bin 文件夹,如 Azure Functions C# developer reference 中所述。 :

Shared assemblies are shared across all functions within a function app. To reference a custom assembly, upload the assembly to your function app, such as in a bin folder in the function app root.

有没有办法做得更好,让我的代码依赖于 nuget 包而不是 dll?

最佳答案

实际的包引用在每个函数中进行管理(即没有函数应用程序级别的包引用集),但是当使用 #load 指令将其带入函数时,共享 CSX 文件将成为该函数的一部分相同的编译单元,并且能够使用函数中定义的程序集/包引用。但您仍然需要在功能级别管理它们。

您可以将#load 行为视为常规 C# 项目中的链接文件,文件被引入其中,但在项目上下文中进行编译。这适用于此处的函数。

关于Azure Functions : Can a shared . csx 使用 nuget 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44406011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com