Source:
<code>public static void main(String[] args) throws InterruptedException { SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v") .setExpires(OffsetDateTime.now().plusYears(1))).subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s \n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.getSecret("BankAccountPassword").subscribe(secretResponse -> System.out.printf("Secret returned with name %s , value %s \n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.getSecret("BankAccountPassword").subscribe(secretResponse -> { Secret secret = secretResponse; secret.setExpires(secret.getExpires().plusYears(1)); secretAsyncClient.updateSecret(secret).subscribe(updatedSecretResponse -> System.out.printf("Secret's updated expiry time %s \n", updatedSecretResponse.getExpires().toString())); }); Thread.sleep(2000); secretAsyncClient.setSecret("BankAccountPassword", "bhjd4DDgsa").subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s \n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.deleteSecret("BankAccountPassword").subscribe(deletedSecretResponse -> System.out.printf("Deleted Secret's Recovery Id %s \n", deletedSecretResponse.getRecoveryId())); Thread.sleep(30000); secretAsyncClient.purgeDeletedSecretWithResponse("BankAccountPassword").subscribe(purgeResponse -> <START> System.out.printf("Bank account secret purge status response %d \n", purgeResponse.getStatusCode())); <END> Thread.sleep(15000); }</code><technical_language>%n</technical_language>

Target:
public static void main(String[] args) throws InterruptedException { SecretAsyncClient secretAsyncClient = new SecretClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); secretAsyncClient.setSecret(new Secret("BankAccountPassword", "f4G34fMh8v") .setExpires(OffsetDateTime.now().plusYears(1))).subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s %n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.getSecret("BankAccountPassword").subscribe(secretResponse -> System.out.printf("Secret returned with name %s , value %s %n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.getSecret("BankAccountPassword").subscribe(secretResponse -> { Secret secret = secretResponse; secret.setExpires(secret.getExpires().plusYears(1)); secretAsyncClient.updateSecret(secret).subscribe(updatedSecretResponse -> System.out.printf("Secret's updated expiry time %s %n", updatedSecretResponse.getExpires().toString())); }); Thread.sleep(2000); secretAsyncClient.setSecret("BankAccountPassword", "bhjd4DDgsa").subscribe(secretResponse -> System.out.printf("Secret is created with name %s and value %s %n", secretResponse.getName(), secretResponse.getValue())); Thread.sleep(2000); secretAsyncClient.deleteSecret("BankAccountPassword").subscribe(deletedSecretResponse -> System.out.printf("Deleted Secret's Recovery Id %s %n", deletedSecretResponse.getRecoveryId())); Thread.sleep(30000); secretAsyncClient.purgeDeletedSecretWithResponse("BankAccountPassword").subscribe(purgeResponse -> System.out.printf("Bank account secret purge status response %d %n", purgeResponse.getStatusCode())); Thread.sleep(15000); }