本文介绍了Azure Functions上的Service Fabric客户端-无法加载DLL'FabricClient.dll'或其依赖项之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Azure Functions上运行的应用程序,包括一个管理应用程序和使用Service Fabric Client API for .NET在Service Fabric群集上运行的服务.

I have an application running on Azure Functions, including a class that manages apps & services running on Service Fabric Cluster using Service Fabric Client API for .NET.

当我从Visual Studio以调试模式在本地运行该应用程序时,该应用程序将运行,并且与Service Fabric Cluster的连接将按预期运行.当我将应用程序部署到Azure Functions时,使用Service Fabric Client API会导致异常:

Application works when I run it locally in debug mode from Visual Studio, and connection to Service Fabric Cluster works as expected. When I deploy the app to Azure Functions, using Service Fabric Client API causes exception:

下面的简化代码.

// SfClientApiHelper.cs

    using System.Fabric;
    using System.Fabric.Description;

    namespace MyService
    {
        class SfClientApiHelper
        {
            private FabricClient Client { get; set; }
            . . .
            public SfClientApiHelper()
            {
                . . .
                this.Client = new FabricClient();
            }

// ClassUsingSfClientApiHelper.cs
         . . .
    SfClientApiHelper sfHelper = new SfClientApiHelper();  // => exception

我在Visual Studio项目上安装了Microsoft.ServiceFabric软件包.我已经从这里安装了win-x64版本的Azure Functions CLI工具. ,并将已建立的目标设置为x64;这些在此处进行指导的 此处).使用zip部署将项目发布到Azure Functions,我从zip部署程序包中检查了它是否包含库'System.Fabric.dll',并使用CorFlags.exe按照指南.

I have Microsoft.ServiceFabric package installed on the Visual Studio project. I have installed win-x64 version of Azure Functions CLI tools from here, and built target is set to x64; these guided here and here). Project is published to Azure Functions using zip deployment, I checked from zip deployment package that it contains library 'System.Fabric.dll', and checked that it is x64 using CorFlags.exe as guided here.

另一个stackoverflow 问题

Another stackoverflow question about the same issue, in the discussion other poor fellow 'tank140' has eventually hit by the same exception. The discussion did not come to any resolution to my understanding.

在本地运行的开发PC上找到丢失的DLL. FabricClient.dll位于文件夹C:\ Program Files \ Microsoft服务Fabric \ bin \ Fabric \ Fabric.Code.可能是因为我在PC上安装了Service Fabric SDK.如何获取此DLL包含在Function Apps项目中以部署到Azure Functions?

Found the missing DLL on my development PC where running locally is working. FabricClient.dll is located in folder C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code. Probably for the reason that I have the Service Fabric SDK installed on the PC.How do I get this DLL included on Function Apps project for deployment to Azure Functions?

我偷看了代码中引用的FabricClient类的定义(请参见下图),根据VisualStudio,该类是在程序集"System.Fabric.dll"中定义的.如图中所示,该项目包含在带有NuGet包'Microsoft.ServiceFabric'的项目中.如前所述,该程序集也包含在部署zip软件包中.在我看来,VS项目和现实之间有些不匹配;可以在本地部署中从未在依赖项中声明的程序集中访问FabricClient类.

I peeked definition of FabricClient class referred in my code (see picture below), according to VisualStudio the class is defined in assembly 'System.Fabric.dll'. This is included in the project with NuGet package 'Microsoft.ServiceFabric' as visible in the picture. As said earlier, this assembly is included also in the deployment zip package. Seems to me that there is some mismatch with VS project and reality; FabricClient class is accessible in local deployment from assembly that is not declared in the dependencies.

推荐答案

您需要在平台上安装SF运行时.

You need the SF runtime to be installed on the platform.

我不确定这是否行得通,但是也许您可以通过使用预先安装了运行时的容器来做到这一点.

I'm not sure if this works, but maybe you can do this by using a container that has the runtime pre-installed.

您可以使用一张名为microsoft/service-fabric-reliableservices-windowsservercore的图片.并且这是创建运行带有自定义映像的(Linux)容器的Azure函数.

There's an image called microsoft/service-fabric-reliableservices-windowsservercore you could use.And here's how to create an Azure Function that runs a (Linux) container with a custom image.

如果您仅创建一个管理其他应用程序和服务的服务,然后在群集上运行它,这可能会更简单.

It will probably be a lot simpler if you just create a service that manages other applications and services, and run it on the cluster.

这篇关于Azure Functions上的Service Fabric客户端-无法加载DLL'FabricClient.dll'或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:51