-
Notifications
You must be signed in to change notification settings - Fork 8
Update key vault data sdk to T2, mangement SDK to latest. #3
Conversation
…" to the value read from app.config. AzureEnvironment.AzureGlobalCloud remains as default.
| /// <summary> | ||
| /// Generic ADAL Authentication callback | ||
| /// </summary> | ||
| public static async Task<string> AcquireTokenAsync(string authority, string resource, string scope) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To track 2, there is new SecretClient instead of KeyVaultClient to use. this AcquireTokenAsync() is used to create KeyVaultClient in KeyvaultSampleBase delegate. So this is decided to remove
KeyVaultSampleBase.cs
Outdated
| // instantiate the data client | ||
| DataClient = new KeyVaultClient(ClientContext.AcquireTokenAsync); | ||
| //Get current Authority Host for Azure | ||
| TokenCredentialOptions options = new TokenCredentialOptions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we did not set options.AuthorityHost, ClientSecretCredential will always set as default "AzureGlobalCloud"
|
Please try with the new preview mgmt libs: https://www.nuget.org/packages/Azure.ResourceManager.KeyVault/1.0.0-preview.1 |
|
Service: KeyVault; SDK: key vault mgmt sdk and azure key vault data sdk(t1)
|
|
@heaths - Can you please review? |
heaths
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a few changes, but otherwise LGTM.
| /// <summary> | ||
| /// Represents the Azure context of the client running the samples - tenant, subscription, client id and credentials. | ||
| /// </summary> | ||
| public sealed class ClientContext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of this class is really used anymore. Perhaps just replace it with the DefaultAzureCredential directly in the client like we normally do in samples. I worry the unnecessary complexity here will just make people copy the design when simply passing a DefaultAzureCredential is so much simpler.
KeyVaultEntityRecoverySamples.cs
Outdated
|
|
||
| // wait for purge complete | ||
| Console.Write("Waiting for Purging complete..."); | ||
| Thread.Sleep(60 * 1000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While sleeping for a bit is a good idea (and there's nothing more we can do anyway), you should actually have a limited retry loop. Purging can take a while, and will vary (it may be a scheduled task in the backend).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@heaths , i am not sure how to implement this limited retry loop. As i think there's nothing more we can do here.
KeyVaultRecoverySamples.cs
Outdated
|
|
||
| Console.Write("Retrieving newly created vault..."); | ||
| var retrievedVault = await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false); | ||
| var retrievedVault = (await sample.ManagementClient.Vaults.GetAsync(rgName, vaultName).ConfigureAwait(false)).Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the sample above, I'd stick with Response<T> here and use its Value property only when needed.
KeyVaultSampleBase.cs
Outdated
| /// </summary> | ||
| protected ClientContext context; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: git doesn't like whitespace-only lines.
README.md
Outdated
| - dotnet-core | ||
| description: "This repo contains sample code demonstrating the backup/restore and recoverable deletion functionality of Azure Key Vault using the Azure .NET SDK." | ||
| urlFragment: net-sdk-samples | ||
| urlFragment: key-vault-dotnet-recovery |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will result in broken links. urlFragment should neve be changed. It's unfortunate it was generic before, but should remain the same. Just be more specific going forward.
README.md
Outdated
| To complete this tutorial: | ||
|
|
||
| The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'. | ||
| * Install .NET Core 2.0 version for [Linux] or [Windows] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.0 is out of support. 2.1 is LTS, but so is 3.1. We should at least recommend an LTS.
README.md
Outdated
| ### Create an App registration using the Azure Portal | ||
|
|
||
| ## Getting Started | ||
| * Go to the [Azure Portal] and log in using your Azure account. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Steps should be numbered. Alternatives should be bulleted.
README.md
Outdated
| [free account]: https://azure.microsoft.com/free/?WT.mc_id=A261C142F | ||
| [Azure Portal]: https://portal.azure.com | ||
| [Recovery scenario samples for Azure Key Vault using the Azure Node SDK]: https://docs.microsoft.com/en-us/samples/azure-samples/key-vault-node-recovery/key-vault-node-recovery/ | ||
| [Azure Key Vault documentation]: https://docs.microsoft.com/en-us/azure/key-vault/general/basic-concepts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLs should not include the locale. In VSCode, install the Microsoft Docs Authoring Pack for rules you should follow when writing markdowns (it would catch this issue).
I see a couple URLs like that. This always goes to the specified language/locale, while leaving it out uses the browsers' preferred languages (better for non-en-US readers).
|
Happy to review, but @jongio or @wantedfast, could I get a review on my sample at Azure/azure-sdk-for-net#15123? It's been sitting there for quite a while. The brunt of it was previously reviewed by Alex at its original home (https://github.com/heaths/KeyVaultProxy), but I had to make a few changes to build / run in our repo, per @weshaggard's desire to host samples in a single place going forward. |
|
@wantedfast @heaths just FYI - .NET SDK team is designing a new set of APIs that will be previewed at the end of year. There can be some upcoming changes in this key vault code sample. The Track 2 .NET SDK won't be GA-ed for a while, so if we expect the customer to see a stable version in a code sample, probably better to stay on Track 1, otherwise, feel free to update to Track 2. |
|
The preview functionality coming out later is in addition to what is here. We're aren't changing anything that is demo'd here. Seems better to show customers more track 2 code since we are deprecating track 1. |
e21e18a to
f406984
Compare
|
If possible, please avoid force-pushing until you're ready to merge (for example, if rebasing on master to pick up recent changes). I can't tell what's changed so I will have to re-review the entire PR again. |
KeyVaultEntityRecoverySamples.cs
Outdated
| catch (CloudException ce) | ||
| { | ||
| Console.WriteLine("Unexpected ARM exception encountered: {0}", ce.Message); | ||
| Console.WriteLine("Unexpected KeyVault exception encountered: {0}", ex.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the product name is "Key Vault" (with a space). We should use that in customer-facing messages / docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
KeyVaultSampleBase.cs
Outdated
| /// </summary> | ||
| protected ClientContext context; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extraneous whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
| To complete this tutorial: | ||
|
|
||
| The recoverable deletion functionality is also referred to as 'soft delete'; consequently, a permanent, irrecoverable deletion is referred to as 'purge'. | ||
| * Install .NET Core 3.1 version for [Linux] or [Windows] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use - consistently throughout the markdown (you use mainly this below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
U mentioned steps need numbered, alternative should be bulleted. I think this is much better than mix them.
Do you still think we should keep consistency or changing below with numbered steps?
Like what i have done now.
|
Sorry for let you review again, this force-pushing is because this PR needs step back. I will be more careful with force-pushing next time. |
Purpose
Update key vault data sdk to T2, key vault management SDK to latest.