title: Binding AzureKeyVault Secrets to a JSON settings file in JAVA
body: <p>I am working on a Java CucumberTest automation project. I am storing the usernames, passwords and other secrets in a json file.</p>
  <pre><code>{
  &quot;adminUsername&quot;:&quot;adminuser&quot;,
  &quot;adminUserPassword&quot;:&quot;Password123&quot;,
  &quot;host-url&quot;:&quot;http://example.com/api/user&quot;,
  &quot;apiKey&quot;:&quot;ak9202zmiwiwkwm&quot;,
  </code></pre>
  <p>}</p>
  <p>The secrets are stored in Azure keyvalut. Currently I am manually copying the values from Azure KeyVault and updated the JSON file. During the execution of tests, the values are read from the json file. However it's not recommended to keep secrets in the code
  What I want to do is:</p>
  <ol>
  <li>When the test run started (Cucumber BeforeAll hook), load the json file</li>
  <li>Loop through the json file through and read each key</li>
  <li>for each key, get the secret value from AzureKeyVault and update the json file with the value for that key.</li>
  </ol>
  <p>I am able to read the value of the secret from AzureKeyVault with this code:</p>
  <pre><code>    String keyVaultName = System.getenv(&quot;KEY_VAULT_NAME&quot;);
      String keyVaultUri = &quot;https://&quot; + keyVaultName + &quot;.vault.azure.net&quot;;
   SecretClient secretClient = new SecretClientBuilder()
                  .vaultUrl(keyVaultUri)
                  .credential(new DefaultAzureCredentialBuilder().build())
                  .buildClient();
          KeyVaultSecret retrievedSecret = secretClient.getSecret(&quot;adminUserPassword&quot;);
          System.out.println(retrievedSecret.getName()+&quot;=&quot;+retrievedSecret.getValue());
  </code></pre>
  <p>I would like update the JSON file contents with the secret value that I just read from KeyVault in memory. And I want to do that for each key in the json file.  I don't want to write to physical file.
  And later I would like to Deserialize the json to an object using ObjectMapper. I already defined a class matching with the JSON file structure.</p>