Source:
public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") .subjectAlternativeNames(SubjectAlternativeNames.fromEmails(Arrays.asList("wow@gmail.com"))) .keyOptions(new EcKeyOptions() .reuseKey(true) .curve(KeyCurveName.P_256)); Map<String, String> tags = new HashMap<>(); tags.put("foo", "bar"); certificateAsyncClient.createCertificate("certificateName", policy, tags) .getObserver().subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().status()); System.out.println(pollResponse.getValue().statusDetails()); }); Thread.sleep(22000); String backupFilePath = "YOUR_BACKUP_FILE_PATH"; certificateAsyncClient.backupCertificate("certificateName") .subscribe(certificateBackupResponse -> { writeBackupToFile(certificateBackupResponse, backupFilePath); System.out.printf("Certificate's Backup Byte array's length %s \n", certificateBackupResponse.length); }); Thread.sleep(7000); certificateAsyncClient.deleteCertificate("certificateName") .subscribe(deletedSecretResponse -> System.out.printf("Deleted Certificate's Recovery Id %s \n", deletedSecretResponse.recoveryId())); Thread.sleep(30000); certificateAsyncClient.purgeDeletedCertificateWithResponse("certificateName") .subscribe(purgeResponse -> System.out.printf("Purge Status response %d \n", purgeResponse.getStatusCode())); Thread.sleep(15000); byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); certificateAsyncClient.restoreCertificate(backupFromFile) .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s \n", certificateResponse.name(), certificateResponse.keyId())); Thread.sleep(15000); }

Target:
public static void main(String[] args) throws IOException, InterruptedException, IllegalArgumentException { CertificateAsyncClient certificateAsyncClient = new CertificateClientBuilder() .endpoint("https://{YOUR_VAULT_NAME}.vault.azure.net") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); CertificatePolicy policy = new CertificatePolicy("Self", "CN=SelfSignedJavaPkcs12") .subjectAlternativeNames(SubjectAlternativeNames.fromEmails(Arrays.asList("wow@gmail.com"))) .keyOptions(new EcKeyOptions() .reuseKey(true) .curve(KeyCurveName.P_256)); Map<String, String> tags = new HashMap<>(); tags.put("foo", "bar"); certificateAsyncClient.createCertificate("certificateName", policy, tags) .getObserver().subscribe(pollResponse -> { System.out.println("---------------------------------------------------------------------------------"); System.out.println(pollResponse.getStatus()); System.out.println(pollResponse.getValue().status()); System.out.println(pollResponse.getValue().statusDetails()); }); Thread.sleep(22000); String backupFilePath = "YOUR_BACKUP_FILE_PATH"; certificateAsyncClient.backupCertificate("certificateName") .subscribe(certificateBackupResponse -> { writeBackupToFile(certificateBackupResponse, backupFilePath); System.out.printf("Certificate's Backup Byte array's length %s %n", certificateBackupResponse.length); }); Thread.sleep(7000); certificateAsyncClient.deleteCertificate("certificateName") .subscribe(deletedSecretResponse -> System.out.printf("Deleted Certificate's Recovery Id %s %n", deletedSecretResponse.recoveryId())); Thread.sleep(30000); certificateAsyncClient.purgeDeletedCertificateWithResponse("certificateName") .subscribe(purgeResponse -> System.out.printf("Purge Status response %d %n", purgeResponse.getStatusCode())); Thread.sleep(15000); byte[] backupFromFile = Files.readAllBytes(new File(backupFilePath).toPath()); certificateAsyncClient.restoreCertificate(backupFromFile) .subscribe(certificateResponse -> System.out.printf("Restored Certificate with name %s and key id %s %n", certificateResponse.name(), certificateResponse.keyId())); Thread.sleep(15000); }