Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

KeyVault configuration fails if release version of Microsoft.Azure.KeyVault referenced #569

Closed
frankbuckley opened this issue Dec 19, 2016 · 16 comments

Comments

@frankbuckley
Copy link
Contributor

Using Microsoft.Extensions.Configuration.AzureKeyVault fails if the project using it (or one of its dependencies) references a release version of Microsoft.Azure.KeyVault.

For example, calling builder.AddAzureKeyVault(...) results in:

Method not found: 'Void Microsoft.Azure.KeyVault.KeyVaultClient..ctor(AuthenticationCallback)'
at Microsoft.Extensions.Configuration.AzureKeyVaultConfigurationExtensions.AddAzureKeyVault(IConfigurationBuilder configurationBuilder, String vault, String clientId, String clientSecret, IKeyVaultSecretManager manager)
at DSE.Services.Api.Startup..ctor(IHostingEnvironment env) in C:\dsedev\src\DSE\Services\src\DSE.Services.Api\Startup.cs:line 42

My guess is this may be because version 2.0.2-preview is referenced?

@divega divega added this to the 1.1.1 milestone Dec 20, 2016
@divega divega added the bug label Dec 20, 2016
@divega
Copy link

divega commented Dec 20, 2016

I confirmed that the current Microsoft.Extensions.Configuration.AzureKeyVault package depends on 2.0.2-preview of Microsoft.Azure.KeyVault. The released version of Microsoft.Azure.KeyVault is 2.0.6 and we can asume it has breaking changes from preview.

@muratg @pakrym any reason not to release a new version of the provider in the 1.1.1 timeframe that depends on realeased bits?

@muratg
Copy link

muratg commented Dec 20, 2016

@divega Let's triage it with the other 1.1.1 items... cc @Eilon

@Eilon
Copy link
Member

Eilon commented Dec 20, 2016

How exactly did we release an RTM package that has a preview dependency??

@Eilon
Copy link
Member

Eilon commented Dec 20, 2016

Logged https://github.com/aspnet/Coherence-Signed/issues/396 to track making sure we don't run into this again.

@pakrym
Copy link
Contributor

pakrym commented Dec 20, 2016

Fixed by: #570

@pakrym pakrym closed this as completed Dec 20, 2016
@Eilon
Copy link
Member

Eilon commented Dec 20, 2016

Re-opening because we need this in 1.1.1.

@Eilon Eilon reopened this Dec 20, 2016
@Eilon
Copy link
Member

Eilon commented Dec 20, 2016

Plus, you didn't mark the bug as 3-Done! 😄

@pavelbrylov
Copy link

Any ETA for 1.1.1 release? We also got this issue today :(

@ryanmcdonnell
Copy link

ryanmcdonnell commented Dec 30, 2016

I was able to work around this by duplicating some of the code in the extension class and passing the callback explicitly:

KeyVaultClient.AuthenticationCallback callback = (authority, resource, scope) => GetTokenFromClientSecret(authority, resource, clientId, clientSecret);
var keyVaultClient = new KeyVaultClient(callback);
configurationBuilder.AddAzureKeyVault(vaultUri, keyVaultClient, new CustomSecretManager(applicationIdentifier));

Also needed to copy the GetTokenFromClientSecret method:

private static async Task<string> GetTokenFromClientSecret(string authority, string resource, string clientId, string clientSecret)
{
    var authContext = new AuthenticationContext(authority);
    var clientCred = new ClientCredential(clientId, clientSecret);
    var result = await authContext.AcquireTokenAsync(resource, clientCred);
    return result.AccessToken;
}

Here's the complete file: https://gist.github.com/ryanmcdonnell/e44319bb6d734a6e2c11742313b44231

@Eilon
Copy link
Member

Eilon commented Dec 30, 2016

@pavelbrylov no ETA, but we hope to get it out as soon as possible in 2017.

@pavelbrylov
Copy link

@Eilon Thanks!

@Eilon
Copy link
Member

Eilon commented Jan 19, 2017

This patch bug is approved. Please use the normal code review process w/ a PR and make sure the fix is in the correct branch, then close the bug and mark it as done.

@pakrym pakrym closed this as completed Feb 9, 2017
@tjrobinson
Copy link

I'm getting this with Microsoft.Azure.KeyVault 2.3.2 when running from an Azure Function, Debug configuration, .NET 4.6.2.

Method not found: 'Void Microsoft.Azure.KeyVault.KeyVaultClient..ctor(AuthenticationCallback, System.Net.Http.DelegatingHandler[])

@divega
Copy link

divega commented Jul 11, 2017

@pakrym @muratg did you see #569 (comment)?

It seems we depend on version 2.3.1 of Microsoft.Azure.KeyVault, and based on the comment above 2.3.2 could contain breaking changes. Was 2.3.1 intentionally chosen? It happens to be unlisted at https://www.nuget.org/packages/Microsoft.Azure.KeyVault/.

@divega
Copy link

divega commented Jul 11, 2017

@tjrobinson thank you for reporting this. I have created #691 to follow up.

@pakrym
Copy link
Contributor

pakrym commented Jul 11, 2017

@divega, it's wasn't intentional we just updated to what was latest at that time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants