Reputation: 582
We are using azure key vault for our azure storage blob encryption. This is the tutorial I followed to get this to work.
I developed a sample application and a wrapper library for encrypting blobs. It all worked well in the sample application. But in the actual software after referencing the wrapper project when the app request the token an exception occurs,
private async Task<string> GetToken(string authority, string resource, string scope)
{
var authContext = new AuthenticationContext(authority);
ClientCredential clientCred = new ClientCredential(ADClientID, ADClientSecret);
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);
if (result == null)
throw new InvalidOperationException("Failed to obtain the JWT token");
return result.AccessToken;
}
In the above code at the line
var authContext = new AuthenticationContext(authority);
The exception it returns is
InnerException = {"Couldn't find type for class Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35."}
What am I doing wrong?
Upvotes: 1
Views: 1346
Reputation: 1991
By default ADAL library using configured TraceSource "Microsoft.IdentityModel.Clients.ActiveDirectory" to write tracing info: https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/blob/51ddc653029a7b3949eb738afbec40dfb30ed6bb/src/ADAL.NET/AdalTrace.cs
See https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/blob/51ddc653029a7b3949eb738afbec40dfb30ed6bb/README.md for more information how to configure tracing .
My assumptions that your web.config has a trace listener pointing to outdated Microsoft.WindowsAzure.Diagnostics. Based on version of Azure .NET SDK installed use appropriate version - latest one is 2.8.0.0. You can also use assembly binding redirects to force loading specific version.
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Diagnostics" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-2.8.0.0" newVersion="2.8.0.0" />
</dependentAssembly>
Upvotes: 2