Service Fabric Client on Azure Functions - Unable to load DLL 'FabricClient.dll' or one of its dependencies


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.

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:

Execution result: Unable to load DLL 'FabricClient.dll' or one of its dependencies: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Simplified code below.

// 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

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.

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.

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?

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.

VS - peek to FabricClient class definition

asked on Stack Overflow Feb 25, 2019 by potsi • edited Mar 1, 2019 by potsi

2 Answers


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.

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.

answered on Stack Overflow Feb 27, 2019 by LoekD

MS answer to my support request:

Service Fabric .Net API is not available for Azure functions because is requires the Service Fabric SDK and runtime to be installed on the platform which cannot be done with an Azure function.

So in your case the options available would be to either rebuild the application to use the Service Fabric REST API and this should be able to run on Azure Functions.

Another option, besides running on a virtual machine, would be to create a custom windows container in which you install the Service Fabric SDK and runtime and them deploy it for example in an Azure Container.

answered on Stack Overflow Mar 1, 2019 by potsi

User contributions licensed under CC BY-SA 3.0