@@ -125,6 +125,18 @@ A `KeyVaultAccessControlClient` manages role definitions and role assignments.
125125### KeyVaultBackupClient
126126A ` KeyVaultBackupClient ` performs full key backups, full key restores, and selective key restores.
127127
128+ ### Pre-Backup Operation
129+ A pre-backup operation represents a long-running operation that checks if it is possible to perform a full key backup.
130+
131+ ### Backup Operation
132+ A backup operation represents a long-running operation for a full key backup.
133+
134+ ### Pre-Restore Operation
135+ A pre-restore operation represents a long-running operation that checks if it is possible to perform a full key restore from a backup.
136+
137+ ### Restore Operation
138+ A restore operation represents a long-running operation for both a full key and selective key restore.
139+
128140### KeyVaultSettingsClient
129141
130142A ` KeyVaultSettingsClient ` manages Managed HSM account settings.
@@ -137,7 +149,9 @@ This section contains code snippets covering common tasks:
137149 * [ List all role assignments] ( #list-all-role-assignments )
138150 * [ Create, get, and delete a role assignment] ( #create-get-and-delete-a-role-assignment )
139151* Backup and restore
152+ * [ Run a pre-backup check] ( #run-a-pre-backup-check-for-a-collection-of-keys )
140153 * [ Perform a full key backup] ( #perform-a-full-key-backup )
154+ * [ Run a pre-restore check] ( #run-a-pre-restore-check-for-a-collection-of-keys )
141155 * [ Perform a full key restore] ( #perform-a-full-key-restore )
142156 * [ Perform a selective key restore] ( #perform-a-selective-key-restore )
143157
@@ -272,18 +286,38 @@ client.delete_role_assignment(scope=scope, name=role_assignment.name)
272286
273287<!-- END SNIPPET -->
274288
275- ### Perform a full key backup
289+ ### Run a pre-backup check for a collection of keys
276290The ` KeyVaultBackupClient ` can be used to back up your entire collection of keys. The backing store for full key
277291backups is a blob storage container using either Managed Identity (which is preferred) or Shared Access Signature (SAS)
278292authentication.
279293
280294If using Managed Identity, first make sure your user-assigned managed identity has the correct access to your Storage
281295account and Managed HSM per [ the service's guidance] [ managed_identity_backup_setup ] .
282296
297+ You can first check if an entire collection of keys can be backed up by using ` KeyVaultBackupClient.begin_pre_backup ` .
298+
283299For more details on creating a SAS token using a ` BlobServiceClient ` from [ ` azure-storage-blob ` ] [ storage_blob ] , refer
284300to the library's [ credential documentation] [ sas_docs ] . Alternatively, it is possible to
285301[ generate a SAS token in Storage Explorer] [ storage_explorer ] .
286302
303+ ``` python
304+ CONTAINER_URL = os.environ[" CONTAINER_URL" ]
305+
306+ check_result: KeyVaultBackupOperation = client.begin_pre_backup(CONTAINER_URL , use_managed_identity = True ).result()
307+
308+ if check_result.error:
309+ print (f " Reason the backup cannot be performed: { check_result.error} " )
310+ else :
311+ print (" A full key backup can be successfully performed." )
312+ ```
313+
314+ Note that the ` begin_pre_backup ` method returns a poller. Calling ` result() ` on this poller returns a
315+ ` KeyVaultBackupOperation ` -- this object will have a string ` error ` attribute if the check failed, and otherwise the
316+ check will have succeeded.
317+
318+ ### Perform a full key backup
319+ To actually perform the key backup, you can use ` KeyVaultBackupClient.begin_backup ` .
320+
287321<!-- SNIPPET:backup_restore_operations.begin_backup -->
288322
289323``` python
@@ -299,7 +333,7 @@ Note that the `begin_backup` method returns a poller. Calling `result()` on this
299333` KeyVaultBackupResult ` containing information about the backup. Calling ` wait() ` on the poller will instead block until
300334the operation is complete without returning an object.
301335
302- ### Perform a full key restore
336+ ### Run a pre-restore check for a collection of keys
303337The ` KeyVaultBackupClient ` can be used to restore your entire collection of keys from a backup. The data source for a
304338full key restore is a storage blob accessed using either Managed Identity (which is preferred) or Shared Access
305339Signature (SAS) authentication. You will also need the URL of the backup (` KeyVaultBackupResult.folder_url ` ) from the
@@ -308,10 +342,31 @@ Signature (SAS) authentication. You will also need the URL of the backup (`KeyVa
308342If using Managed Identity, first make sure your user-assigned managed identity has the correct access to your Storage
309343account and Managed HSM per [ the service's guidance] [ managed_identity_backup_setup ] .
310344
345+ You can first check if an entire collection of keys can be restored from a backup by using
346+ ` KeyVaultBackupClient.begin_pre_restore ` .
347+
311348For more details on creating a SAS token using a ` BlobServiceClient ` from [ ` azure-storage-blob ` ] [ storage_blob ] , refer
312349to the library's [ credential documentation] [ sas_docs ] . Alternatively, it is possible to
313350[ generate a SAS token in Storage Explorer] [ storage_explorer ] .
314351
352+ ``` python
353+ check_result: KeyVaultRestoreOperation = client.begin_pre_restore(
354+ backup_result.folder_url, use_managed_identity = True
355+ ).result()
356+
357+ if check_result.error:
358+ print (f " Reason the backup cannot be performed: { check_result.error} " )
359+ else :
360+ print (" A full key restore can be successfully performed." )
361+ ```
362+
363+ Note that the ` begin_pre_restore ` method returns a poller. Calling ` result() ` on this poller returns a
364+ ` KeyVaultRestoreOperation ` -- this object will have a string ` error ` attribute if the check failed, and otherwise the
365+ ` error ` will be None if the check succeeded.
366+
367+ ### Perform a full key restore
368+ To actually restore your entire collection of keys, you can use ` KeyVaultBackupClient.begin_restore ` .
369+
315370<!-- SNIPPET:backup_restore_operations.begin_restore -->
316371
317372``` python
0 commit comments