gpt4 book ai didi

azure - 在 Azure Functions 中将共享程序集的依赖项放置在何处

转载 作者:行者123 更新时间:2023-12-02 04:04:35 25 4
gpt4 key购买 nike

我在azure函数中遇到了私有(private)程序集的奇怪问题,我有一个带有五个函数的Azure函数应用程序,其中有一个共享的bin文件夹,我在其中放置程序集,这些程序集又依赖于我所拥有的 Entity Framework 和LinqKit在每个函数的所有project.json 文件中添加了依赖项,但私有(private)程序集无法获取对这些依赖项的引用并且失败。请帮忙。项目.json --

{
"frameworks": {
"net46":{
"dependencies": {
"EntityFramework": "6.1.3",
"Newtonsoft.Json": "9.0.1",
"LinqKit": "1.1.7.2"
}
}
}
}

为了在我的函数应用程序中进一步澄清,我有五个不同的函数,它们依赖于 2 个私有(private)程序集,并且我不想在每个函数中保留单独的副本(因为这可能会导致不同文件夹中同一 dll 的不同版本导致问题)所以我创建了一个共享 bin 文件夹,从中引用私有(private)程序集,但问题发生是因为这些私有(private)程序集进一步依赖于一些他们无法找到它们的 nuget 包 -

#r "..\bin\Marketware.Domain.dll"
#r "..\bin\Marketware.AzureIntegration.dll"

using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics.Eventing.Reader;

最佳答案

如果您想使用私有(private)程序集(不是来自 nuget),您必须执行以下操作:

  1. 连接到 Functions 应用 ftp
  2. 在包含您的函数的文件夹中创建 bin 文件夹(其中包含 run.csx)
  3. 将自定义程序集上传到新创建的 bin 文件夹
  4. 更新函数代码并添加引用

不幸的是,这个 dll 需要位于每个需要的函数文件夹中。

示例

#r "CustomAssembly.dll"

using System.Net;
using CustomAssembly;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
CustomAssemblyClass.MethodName(); // here call your method
return req.CreateResponse(HttpStatusCode.OK, "");
}

关于azure - 在 Azure Functions 中将共享程序集的依赖项放置在何处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40133324/

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