Class KeyVaultBackupAsyncClient
- java.lang.Object
-
- com.azure.security.keyvault.administration.KeyVaultBackupAsyncClient
-
public final class KeyVaultBackupAsyncClient extends Object
TheKeyVaultBackupAsyncClient
provides asynchronous methods to perform full backup and restore of an Azure Key Vault.Instances of this client are obtained by calling the
KeyVaultBackupClientBuilder.buildAsyncClient()
method on aKeyVaultBackupClientBuilder
object.Samples to construct an async client
KeyVaultBackupAsyncClient keyVaultBackupAsyncClient = new KeyVaultBackupClientBuilder() .vaultUrl("https://myaccount.managedhsm.azure.net/") .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient();
- See Also:
KeyVaultBackupClientBuilder
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.azure.core.util.polling.PollerFlux<KeyVaultBackupOperation,String>
beginBackup(String blobStorageUrl, String sasToken)
Initiates a full backup of the Key Vault.com.azure.core.util.polling.PollerFlux<KeyVaultRestoreOperation,KeyVaultRestoreResult>
beginRestore(String folderUrl, String sasToken)
Initiates a full restore of the Key Vault.com.azure.core.util.polling.PollerFlux<KeyVaultSelectiveKeyRestoreOperation,KeyVaultSelectiveKeyRestoreResult>
beginSelectiveKeyRestore(String keyName, String folderUrl, String sasToken)
Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob storage backup folder.String
getVaultUrl()
Gets the URL for the Key Vault this client is associated with.
-
-
-
Method Detail
-
getVaultUrl
public String getVaultUrl()
Gets the URL for the Key Vault this client is associated with.- Returns:
- The Key Vault URL.
-
beginBackup
public com.azure.core.util.polling.PollerFlux<KeyVaultBackupOperation,String> beginBackup(String blobStorageUrl, String sasToken)
Initiates a full backup of the Key Vault.Code Samples
Starts a
backup operation
, polls for its status and waits for it to complete. Prints out the details of the operation's final result in case of success or prints out details of an error in case the operation fails.String blobStorageUrl = "https://myaccount.blob.core.windows.net/myContainer"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z" + "&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; client.beginBackup(blobStorageUrl, sasToken) .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. .doOnError(e -> System.out.printf("Backup failed with error: %s.%n", e.getMessage())) .doOnNext(pollResponse -> System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(folderUrl -> System.out.printf("Backup completed. The storage location of this backup is: %s.%n", folderUrl));
- Parameters:
blobStorageUrl
- The URL for the Blob Storage resource where the backup will be located.sasToken
- A Shared Access Signature (SAS) token to authorize access to the blob.- Returns:
- A
PollerFlux
polling on thebackup operation
status. - Throws:
KeyVaultAdministrationException
- If the givenblobStorageUrl
orsasToken
are invalid.NullPointerException
- If theblobStorageUrl
orsasToken
arenull
.
-
beginRestore
public com.azure.core.util.polling.PollerFlux<KeyVaultRestoreOperation,KeyVaultRestoreResult> beginRestore(String folderUrl, String sasToken)
Initiates a full restore of the Key Vault.Code Samples
Starts a
restore operation
, polls for its status and waits for it to complete. Prints out error details in case the operation fails.String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z" + "&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; client.beginRestore(folderUrl, sasToken) .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. .doOnError(e -> System.out.printf("Restore failed with error: %s.%n", e.getMessage())) .doOnNext(pollResponse -> System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(unused -> System.out.printf("Backup restored successfully.%n"));
- Parameters:
folderUrl
- The URL for the Blob Storage resource where the backup is located, including the path to the blob container where the backup resides. This would be the exact value that is returned as the result of a backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313.sasToken
- A Shared Access Signature (SAS) token to authorize access to the blob.- Returns:
- A
PollerFlux
polling on therestore operation
status. - Throws:
KeyVaultAdministrationException
- If the givenfolderUrl
orsasToken
are invalid.NullPointerException
- If thefolderUrl
orsasToken
arenull
.
-
beginSelectiveKeyRestore
public com.azure.core.util.polling.PollerFlux<KeyVaultSelectiveKeyRestoreOperation,KeyVaultSelectiveKeyRestoreResult> beginSelectiveKeyRestore(String keyName, String folderUrl, String sasToken)
Restores all versions of a given key using the supplied SAS token pointing to a previously stored Azure Blob storage backup folder.Code Samples
Starts a
selective key restore operation
, polls for its status and waits for it to complete. Prints out error details in case the operation fails.String folderUrl = "https://myaccount.blob.core.windows.net/myContainer/mhsm-myaccount-2020090117323313"; String sasToken = "sv=2020-02-10&ss=b&srt=o&sp=rwdlactfx&se=2021-06-17T07:13:07Z&st=2021-06-16T23:13:07Z" + "&spr=https&sig=n5V6fnlkViEF9b7ij%2FttTHNwO2BdFIHKHppRxGAyJdc%3D"; String keyName = "myKey"; client.beginSelectiveKeyRestore(folderUrl, sasToken, keyName) .setPollInterval(Duration.ofSeconds(1)) // You can set a custom polling interval. .doOnError(e -> System.out.printf("Key restoration failed with error: %s.%n", e.getMessage())) .doOnNext(pollResponse -> System.out.printf("The current status of the operation is: %s.%n", pollResponse.getStatus())) .filter(pollResponse -> pollResponse.getStatus() == LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) .flatMap(AsyncPollResponse::getFinalResult) .subscribe(unused -> System.out.printf("Key restored successfully.%n"));
- Parameters:
keyName
- The name of the key to be restored.folderUrl
- The URL for the Blob Storage resource where the backup is located, including the path to the blob container where the backup resides. This would be the exact value that is returned as the result of a backup operation. An example of such a URL may look like the following: https://contoso.blob.core.windows.net/backup/mhsm-contoso-2020090117323313.sasToken
- A Shared Access Signature (SAS) token to authorize access to the blob.- Returns:
- A
PollerFlux
polling on therestore operation
status. - Throws:
KeyVaultAdministrationException
- If the givenkeyName
,folderUrl
orsasToken
are invalid.NullPointerException
- If thekeyName
,folderUrl
orsasToken
arenull
.
-
-