本文介绍了无法使用Azure函数加载文件或程序集System.Fabric的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与Azure Functions一起使用的软件包是否有任何限制.我已经尽力进行了研究,但似乎还没有,但是,当我尝试创建引用程序包"Microsoft.ServiceFabric"的Azure函数时,出现以下错误:

Are there any restrictions with packages you can use with Azure Functions. I have researched as much as I can and it doesn't seem so, however when I try creating an Azure Function that references the package "Microsoft.ServiceFabric" I get the following error:

我曾经尝试过Azure Func和.1和2,以及.Net Framework和.Net Core都没有运气.

I have tried both Azure Func and.1 and 2, and .Net Framework and .Net Core with no luck.

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using System.Fabric;

namespace FunctionApp5
{
  public static class Function1
  {
    [FunctionName("Function1")]
    public static void Run([TimerTrigger("*/5 * * * * *")]TimerInfo myTimer, ILogger log)
    {
      log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
      FabricClient client = new FabricClient();
    }
  }
}

这是可能的,还是Visual Studio中Azure功能的限制-如果可以,那么可以接受哪些程序包?

Is this possible, or a limitation of Azure Functions in Visual Studio - if so, what packages are acceptable?

推荐答案

  • ServiceFabric软件包是x64位,如果您的功能目标是32位,则它将失败.尝试刘杰(Jerry Liu)提出的解决方案
  • 由于服务对其他库的依赖性,必须将
  • Service Fabric软件包作为软件包添加,而不是直接在项目中引用dll.您应该添加NuGet包Microsoft.ServiceFabric.
  • Microsoft.ServiceFabric最新版本6.3.x的目标是.Net Standard 2.0.Net Framework4.54.7.1,请确保在项目中使用其中的任何一个.
  • 确保在构建\部署后将Microsoft.ServiceFabric DLL复制到bin文件夹中.
  • 在群集外部使用FabricClient时,必须指定设置和凭据,否则将无法连接到群集.请参见示例和文档.
  • FabricClient使用服务结构API 进行交互在集群中,如果软件包有问题,另一种选择是使用HttpClient并向API发出请求,从而避免软件包冲突
    • ServiceFabric packages are x64 bit, if your function target 32bit it will fail. Try the solution proposed by Jerry Liu
    • Service Fabric Packages have to be added as packages instead of reference the dll directly in the project, because of the dependencies on other libraries. You should add the NuGet package Microsoft.ServiceFabric.
    • Microsoft.ServiceFabric latest version 6.3.x targets .Net Standard 2.0 and .Net Framework from 4.5 to 4.7.1, make sure you are using any of these on your project.
    • Make sure the Microsoft.ServiceFabric DLLs are being copied to the bin folder when built\deployed.
    • When you use FabricClient outside the cluster, you have to specify the settings and credentials, otherwise you won't be able to connect to the cluster. See this example and this docs.
    • FabricClient uses Service Fabric API to interact with the cluster, if are having issues with the packages, another option is use HttpClient and make the requests to the API and avoid the packages conflicts
    • 这篇关于无法使用Azure函数加载文件或程序集System.Fabric的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:53