ASP.NET Core using Azure KeyVault - Error on delegating the KeyVaultClient.AuthenticationCallback
<p>I want to integrate my project on ASP.NET Core 1.0 with Microsoft Azure KeyVault. But it seems like Microsoft.Azure.KeyVault package is not compatible yet with "netcoreapp1.0" framework (I try to download the package using NuGet package manager and the "incompatible package" error message is shown). Therefore I import "net451" framework in the project.json shown in this block:</p>

<pre><code>"frameworks": {
"netcoreapp1.0": {
  "imports": [
    "net451",
    "dotnet5.6",
    "portable-net45+win8"
    ]
  }  
},
</code></pre>

<p>After importing "net451" framework, the error is now gone. Now I want to initiate a new KeyVaultClient class shown in this block:</p>

<pre><code>public void GetKeyVaultSecret()
{
    var keyVaultClient = new KeyVaultClient(this.GetTokenAsync);
    // ....
}

private async Task&lt;string&gt; GetTokenAsync(string authority, string resource, string scope)
{
    var authenticationContext = new AuthenticationContext(authority);
    var authenticationResult =
        await authenticationContext.AcquireTokenAsync(resource, this.clientAssertionCertificate);
    return authenticationResult.AccessToken;
}
</code></pre>

<p>The problem is I got this error message on <code>this.GetTokenAsync</code> which I have search the solution for hours without any luck: <code>Argument 1:cannot convert from 'method group' to 'KeyVaultClient.AuthenticationCallback'</code></p>

<p>If I change</p>

<pre><code>var keyVaultClient = new KeyVaultClient(this.GetTokenAsync);
</code></pre>

<p>to:</p>

<pre><code>var keyVaultClient = new KeyVaultClient((authority, resource, scope) =&gt; this.GetTokenAsync(authority, resource, string.Empty));
</code></pre>

<p>I still got error message: <code>Cannot convert lambda expression to type 'KeyVaultClient.AuthenticationCallback' because it is not a delegate type</code></p>

<p>Anybody knows how to solve this problem? Thanks.</p>

<p>Regards,
Alvin</p>