microsoft / AzureKeyVaultExplorer

Azure Key Vault Explorer
MIT License
210 stars 68 forks source link

Cannot add VaultAliases.json entry w/o corresponding entry in Vaults.json #48

Open aaronpburke opened 2 years ago

aaronpburke commented 2 years ago

If I have a default Vaults.json file (empty), the documentation states that I should be able to add a simple Vault entry to the dropdown by adding the following to VaultAliases.json (using default AAD auth). I assume this behavior is likely true for any entry in VaultAliases.json without a corresponding entry in Vaults.json:

[
  {
    "Alias": "MyVault",
    "VaultNames": [ "MyVault" ]
  }
]

But when I do, it throws the following exception:

System.Collections.Generic.KeyNotFoundException: MachineTranslationInt is not found in C:\Users\aaburke\OneDrive - Microsoft\AKVExplorer\Vaults.json
   at Microsoft.Vault.Library.Vault.<>c__DisplayClass19_0.<CreateKeyVaultClientEx>b__0(String authority, String resource, String scope)
   at Microsoft.Azure.KeyVault.KeyVaultCredential.<PreAuthenticate>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.KeyVault.KeyVaultCredential.<ProcessHttpRequestAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.KeyVault.KeyVaultClient.<GetSecretsWithHttpMessagesAsync>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.KeyVault.KeyVaultClientExtensions.<GetSecretsAsync>d__39.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Vault.Library.Vault.<ListSecretsAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Vault.Explorer.MainForm.<>c__DisplayClass32_1.<<uxMenuItemRefresh_Click>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Vault.Explorer.UxOperation.<>c__DisplayClass12_1.<<Invoke>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Vault.Explorer.UxOperation.<Invoke>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Vault.Explorer.MainForm.<uxMenuItemRefresh_Click>d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Adding the following to Vaults.json fixes the issue:

[
  {
    "Alias": "MyVault",
    "VaultNames": [ "MyVault" ]
  }
]

This is in contrast to the documentation, which states:

Here is an example of a single vault not defined in Vaults.json

  {
    "Alias": "DEV",
    "VaultNames": [ "TestKeyVault" ]
  }
VictorioBerra commented 1 year ago

Same issue.