Esempio n. 1
0
 public void Invoke(CancellationToken cancellationToken)
 {
     if (cancellationToken.IsCancellationRequested)
     {
         return;
     }
     ThreadHelper.JoinableTaskFactory.Run(() =>
     {
         string name, secret;
         var prompt = new Prompt();
         prompt.promptMessage.Text = "Supply the name for the secret!";
         prompt.ShowDialog();
         name = prompt.ResponseText;
         if (name is null || name == string.Empty)
         {
             return(System.Threading.Tasks.Task.CompletedTask);
         }
         var promptv = new Prompt();
         promptv.promptMessage.Text = "Validate the secret (remove '', etc.)!";
         promptv.ResponseText       = value;
         promptv.ShowDialog();
         secret = promptv.ResponseText;
         if (secret is null || secret == string.Empty)
         {
             return(System.Threading.Tasks.Task.CompletedTask);
         }
         var vaultClient = new Microsoft.Azure.KeyVault.KeyVaultClient(new KeyVaultClient.AuthenticationCallback(new AzureServiceTokenProvider().KeyVaultTokenCallback));
         vaultClient.SetSecretAsync(Options.Instance.AKVUrl, name, secret).Wait();
         string aKVUrl = language == "PowerShell" || language == "InBoxPowerShell" ? Options.Instance.AKVShortName : Options.Instance.AKVUrl;
         _span.TextBuffer.Replace(_span.GetSpan(_snapshot), string.Format(replacementTexts[language], aKVUrl, name));
         return(System.Threading.Tasks.Task.CompletedTask);
     });
 }
Esempio n. 2
0
 public async Task SetSecretValueAsync(string secretName, string secretValue)
 {
     await _client.SetSecretAsync(_keyVault, secretName, secretValue);
 }