Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KeyClient.GetCryptographyClient #23856

Merged
merged 2 commits into from Sep 10, 2021
Merged

Add KeyClient.GetCryptographyClient #23856

merged 2 commits into from Sep 10, 2021

Conversation

heaths
Copy link
Member

@heaths heaths commented Sep 8, 2021

Resolves #23786

@annelo-msft
Copy link
Member

Out of curiosity, what motivates this update? Is it just the guidelines change, or is there a customer scenario that calls for it? If the latter, it might be worth adding something to samples to show users how to call the method, and indicate when/why they'd want to do this instead of newing a CryptographyClient directly.

@heaths
Copy link
Member Author

heaths commented Sep 8, 2021

Just for the guidelines change. It may also improve the discoverability. I can add (or modify) a sample, though.

Comment on lines 1362 to 1364
internal static Uri CreateKeyUri(Uri vaultUri, string name, string version) => version is null
? new Uri(vaultUri, KeysPath + name)
: new Uri(vaultUri, $"{KeysPath}{name}/{version}");
Copy link
Member

@vhvb1989 vhvb1989 Sep 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid adding this method by calling keyClient.GetKey(name, version) and then using the returned key to create the crypto client? (That's how I was thinking to implement this for C++) .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about dotnet or C++, but just chatted with JS architects and in JS we would not have an async get<Subclient> method and it would need to be async if we want to call keyClient.GetKey

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes I forget that C++ is the only lang with all APIs being Sync. So there's not such restriction for C++ to consider the Async world.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method you highlighted just creates a URI, which your CryptographyClient should already take in its public constructor. We also already have methods that get you a KeyVaultKey, from which you can get a JsonWebKey, which users should be able to pass to a CryptographyClient already.

There's no reason to have an async version of any methods I added because methods are sync or async, not classes. That may not be true of Python and Java, however, which have separate classes but might choose to have 1 method on each that returns the same "syncedness" client (that's what I'd do, but talk with your architects).

@heaths
Copy link
Member Author

heaths commented Sep 8, 2021

Adding "Do Not Merge" until @KrzysztofCwalina, @tg-msft, or @schaabs can review.

Copy link
Member

@tg-msft tg-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

@heaths heaths merged commit dcd0678 into Azure:main Sep 10, 2021
@heaths heaths deleted the issue23786 branch September 10, 2021 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define KeyClient.GetCryptographyClient to return a CryptographyClient with shared pipeline
5 participants