title: Service Fabric Client on Azure Functions - Unable to load DLL 'FabricClient.dll' or one of its dependencies
body: <p>I have an application running on Azure Functions, including a class that manages apps &amp; services running on Service Fabric Cluster using Service Fabric Client API for .NET. </p>
  
  <p>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: </p>
  
  <blockquote>
    <p>Execution result: Unable to load DLL 'FabricClient.dll' or one of its
    dependencies: The specified module could not be found. (Exception from
    HRESULT: 0x8007007E)</p>
  </blockquote>
  
  <p>Simplified code below.</p>
  
  <pre><code>// 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();  // =&gt; exception
  </code></pre>
  
  <p>I have Microsoft.ServiceFabric package installed on the Visual Studio project. I have installed win-x64 version of Azure Functions CLI tools from <a href="https://github.com/Azure/azure-functions-core-tools/releases" rel="nofollow noreferrer">here</a>, and built target is set to x64; these guided <a href="https://stackoverflow.com/questions/53276947/could-not-load-file-or-assembly-system-fabric-with-azure-functions/53297829">here</a> and <a href="https://www.henkboelman.com/azure-function-x64-dev-setup/" rel="nofollow noreferrer">here</a>). 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 <a href="https://stackoverflow.com/questions/270531/how-to-determine-if-a-net-assembly-was-built-for-x86-or-x64">here</a>. </p>
  
  <p>Another stackoverflow <a href="https://stackoverflow.com/questions/53276947/could-not-load-file-or-assembly-system-fabric-with-azure-functions/53297829">question</a> 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.</p>
  
  <p>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?</p>
  
  <p>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.</p>
  
  <p><a href="https://i.stack.imgur.com/fRUQj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fRUQj.png" alt="VS - peek to FabricClient class definition"></a></p>