繁体   English   中英

如何在Azure函数中引用多个外部程序集?

[英]How to reference multiple external assemblies in an Azure function?

到目前为止,我的Azure功能仅依赖于一个外部程序集(Assembly1),并且运行良好。

但是,最近我们不得不做一些更改,由于现在有两个外部程序集,其中Assembly1引用了Assembly2。

我已将Assembly2部署为与Assembly1相同(我是说,将.dll复制到Azure函数的“ bin”文件夹中,并使用“ #r Assembly2”语句将其导入到Azure函数中。

这给了我以下编译错误-

执行函数时发生异常:Functions.ProcessCsvRows。 Assembly1:无法加载文件或程序集'Assembly2,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空'或其依赖项之一。 该系统找不到指定的文件。 函数已启动(Id = dc837832-9303-4ae4-a8ae-133ab531250c)无法找到程序集'Assembly2,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空'。 您是否缺少私人组装文件?

请在代码下方找到有关此内容的更多详细信息-

#r "Assembly1"
#r "Assembly2"

using System;
using System.Net;
using Newtonsoft.Json;
using System.IO;
using System.Collections.Generic;
using System.Configuration;
using Assembly1.Entities;

public static async Task<object> Run(HttpRequestMessage req, TraceWriter log){
    var jsonContent = await req.Content.ReadAsStringAsync();
    dynamic data = JsonConvert.DeserializeObject(jsonContent.ToString());
    ProcessCsvFileContents_Result _processResponse = await DataProcessor.ProcessCsvFileContents(data.FileContent.ToString(), connectionString, clientId, redirectUrl); // DataProcessor exists in Assembly1 only
    -- response processing code -- 
}

非常感谢您对此提供的任何帮助。

尼尔曼

私有程序集应以其扩展名(例如.dll)引用。 看起来您遇到了执行失败(编译成功)

您能否检查以下内容:

  1. 确保assembly1.dll和assembly2.dll都位于该函数文件夹中的bin文件夹中
  2. 如果在部署文件之前更新了功能参考,则绑定可能会失败。 您能否重新启动您的Function App (重新启动网站)

希望这可以帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM