service-fabric
service-fabric copied to clipboard
Could not load System.Fabric.AzureActiveDirectory.Client when using FabricClient to connect to an AAD-secured cluster
Connecting to a cluster secured with AAD using FabricClient in C# crashes with the following exception:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Fabric.AzureActiveDirectory.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
at GetAccessToken(Char* authority, Char* audience, Char* client, Char* redirectUri, Boolean refreshSession, Char* outBuffer, Int32 outBufferSize)
Example code from a regular C# Console Application, assuming the destination cluster has AAD authentication enabled:
string serverCertThumb = "A8136758F4AB8962AF2BF3F27921BE1DF67F4326";
string connection = "clustername.westus.cloudapp.azure.com:19000";
var claimsCredentials = new ClaimsCredentials();
claimsCredentials.ServerThumbprints.Add(serverCertThumb);
var fc = new FabricClient(claimsCredentials, connection);
var ret = fc.ClusterManager.GetClusterManifestAsync().GetAwaiter().GetResult(); ;
Console.WriteLine(ret.ToString());
If I add a reference to System.Fabric.AzureActiveDirectory.Client.dll
to the Console App manually from the Service Fabric installation directory, then it works, but that assembly should be loaded automatically if it is a dependency. Note that the application compiles, but crashes at runtime.
Cluster version: 6.1.472 Microsoft.ServiceFabric package version: 6.1.472 Local runtime version installed: 6.1.472 Local OS: Windows 10
How did you add System.Fabric.dll though?
System.Fabric.dll comes with the Microsoft.ServiceFabric NuGet package.
Experiencing this as well. Any updates? @athinanthny
System.Fabric.dll comes with the Microsoft.ServiceFabric NuGet package.
This is completely unhelpful.
The DLL in question that is needed by the client but not distributed with it is System.Fabric.AzureActiveDirectory.Client.dll
On my machine I found it in C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code
You will also need https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/
Good luck making all of this work. I gave up.