Skip to content

Commit 2f95178

Browse files
authored
[Key Vault] Add 7.6-preview.2 support (Azure#37507)
1 parent df08aa8 commit 2f95178

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+849
-146
lines changed

sdk/keyvault/azure-keyvault-administration/CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Release History
22

3-
## 4.5.1 (Unreleased)
3+
## 4.6.0b1 (2025-03-20)
44

55
### Features Added
6-
7-
### Breaking Changes
8-
9-
### Bugs Fixed
6+
- Added support for service API version `7.6-preview.2`
7+
- Added `KeyVaultBackupClient.begin_pre_backup` and `KeyVaultBackupClient.begin_pre_restore` methods for checking if it
8+
is possible to perform a full key backup or full key restore
9+
[#37507](https://github.com/Azure/azure-sdk-for-python/pull/37507)
1010

1111
### Other Changes
1212
- Updated minimum `typing-extensions` version to 4.6.0

sdk/keyvault/azure-keyvault-administration/README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ A `KeyVaultAccessControlClient` manages role definitions and role assignments.
125125
### KeyVaultBackupClient
126126
A `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

130142
A `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
276290
The `KeyVaultBackupClient` can be used to back up your entire collection of keys. The backing store for full key
277291
backups is a blob storage container using either Managed Identity (which is preferred) or Shared Access Signature (SAS)
278292
authentication.
279293

280294
If using Managed Identity, first make sure your user-assigned managed identity has the correct access to your Storage
281295
account 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+
283299
For more details on creating a SAS token using a `BlobServiceClient` from [`azure-storage-blob`][storage_blob], refer
284300
to 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
300334
the 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
303337
The `KeyVaultBackupClient` can be used to restore your entire collection of keys from a backup. The data source for a
304338
full key restore is a storage blob accessed using either Managed Identity (which is preferred) or Shared Access
305339
Signature (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
308342
If using Managed Identity, first make sure your user-assigned managed identity has the correct access to your Storage
309343
account 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+
311348
For more details on creating a SAS token using a `BlobServiceClient` from [`azure-storage-blob`][storage_blob], refer
312349
to 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

sdk/keyvault/azure-keyvault-administration/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/keyvault/azure-keyvault-administration",
5-
"Tag": "python/keyvault/azure-keyvault-administration_a67edcfd4d"
5+
"Tag": "python/keyvault/azure-keyvault-administration_979123dade"
66
}

sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
from ._enums import KeyVaultRoleScope, KeyVaultDataAction, KeyVaultSettingType
88
from ._internal.client_base import ApiVersion
99
from ._models import (
10+
KeyVaultBackupOperation,
1011
KeyVaultBackupResult,
1112
KeyVaultPermission,
13+
KeyVaultRestoreOperation,
1214
KeyVaultRoleAssignment,
1315
KeyVaultRoleAssignmentProperties,
1416
KeyVaultRoleDefinition,
@@ -19,11 +21,13 @@
1921

2022
__all__ = [
2123
"ApiVersion",
24+
"KeyVaultBackupOperation",
2225
"KeyVaultBackupResult",
2326
"KeyVaultAccessControlClient",
2427
"KeyVaultBackupClient",
2528
"KeyVaultDataAction",
2629
"KeyVaultPermission",
30+
"KeyVaultRestoreOperation",
2731
"KeyVaultRoleAssignment",
2832
"KeyVaultRoleAssignmentProperties",
2933
"KeyVaultRoleDefinition",

0 commit comments

Comments
 (0)