简体   繁体   English

Windows Azure密钥库广告身份验证对于某些项目失败

[英]Windows Azure key vault ad authentication fails for some projects

We are using azure key vault for our azure storage blob encryption. 我们正在使用azure密钥保险库进行azure存储Blob加密。 This is the tutorial I followed to get this to work. 是我遵循的教程,以使其正常工作。

I developed a sample application and a wrapper library for encrypting blobs. 我开发了一个示例应用程序和一个用于加密Blob的包装器库。 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? 我究竟做错了什么?

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 默认情况下,使用配置的TraceSource“ Microsoft.IdentityModel.Clients.ActiveDirectory”的ADAL库编写跟踪信息: 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 . 有关如何配置跟踪的更多信息,请参见https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/blob/51ddc653029a7b3949eb738afbec40dfb30ed6bb/README.md

My assumptions that your web.config has a trace listener pointing to outdated Microsoft.WindowsAzure.Diagnostics. 我假设您的web.config具有指向过时的Microsoft.WindowsAzure.Diagnostics的跟踪侦听器。 Based on version of Azure .NET SDK installed use appropriate version - latest one is 2.8.0.0. 基于安装的Azure .NET SDK版本使用适当的版本-最新版本为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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM