0
# Vault Management
1
2
Comprehensive functionality for managing Azure Recovery Services vaults including creation, configuration, updates, deletion, and querying. Recovery Services vaults serve as containers for backup and disaster recovery operations, providing secure storage and management capabilities for protecting Azure resources.
3
4
## Capabilities
5
6
### List Vaults by Subscription
7
8
Retrieves all Recovery Services vaults in the specified Azure subscription.
9
10
```python { .api }
11
def list_by_subscription_id(**kwargs) -> ItemPaged[Vault]:
12
"""
13
Fetches all the recovery services vaults in the subscription.
14
15
Returns:
16
ItemPaged[Vault]: An iterator of Vault objects
17
"""
18
```
19
20
**Usage Example:**
21
22
```python
23
# List all vaults in subscription
24
vaults = client.vaults.list_by_subscription_id()
25
for vault in vaults:
26
print(f"Vault: {vault.name}")
27
print(f" Location: {vault.location}")
28
print(f" SKU: {vault.sku.name}")
29
print(f" Resource Group: {vault.id.split('/')[4]}")
30
```
31
32
### List Vaults by Resource Group
33
34
Retrieves all Recovery Services vaults within a specific resource group.
35
36
```python { .api }
37
def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[Vault]:
38
"""
39
Retrieve a list of vaults within the given resource group.
40
41
Parameters:
42
- resource_group_name: str - The name of the resource group
43
44
Returns:
45
ItemPaged[Vault]: An iterator of Vault objects
46
"""
47
```
48
49
**Usage Example:**
50
51
```python
52
# List vaults in specific resource group
53
resource_group = "my-backup-rg"
54
vaults = client.vaults.list_by_resource_group(resource_group)
55
for vault in vaults:
56
print(f"Vault: {vault.name} in {vault.location}")
57
```
58
59
### Get Vault Details
60
61
Retrieves detailed information about a specific Recovery Services vault.
62
63
```python { .api }
64
def get(resource_group_name: str, vault_name: str, **kwargs) -> Vault:
65
"""
66
Get the details of the recovery services vault.
67
68
Parameters:
69
- resource_group_name: str - The name of the resource group
70
- vault_name: str - The name of the recovery services vault
71
72
Returns:
73
Vault: The vault resource
74
"""
75
```
76
77
**Usage Example:**
78
79
```python
80
# Get specific vault details
81
vault = client.vaults.get("my-rg", "my-vault")
82
print(f"Vault ID: {vault.id}")
83
print(f"Properties: {vault.properties}")
84
print(f"Identity: {vault.identity}")
85
86
# Access vault properties
87
if vault.properties:
88
print(f"Private Endpoint Connections: {len(vault.properties.private_endpoint_connections or [])}")
89
print(f"Encryption: {vault.properties.encryption}")
90
```
91
92
### Create or Update Vault
93
94
Creates a new Recovery Services vault or updates an existing one. This is a long-running operation.
95
96
```python { .api }
97
def begin_create_or_update(
98
resource_group_name: str,
99
vault_name: str,
100
vault: Union[Vault, IO[bytes]],
101
x_ms_authorization_auxiliary: Optional[str] = None,
102
**kwargs
103
) -> LROPoller[Vault]:
104
"""
105
Creates or updates a Recovery Services vault.
106
107
Parameters:
108
- resource_group_name: str - The name of the resource group
109
- vault_name: str - The name of the recovery services vault
110
- vault: Union[Vault, IO[bytes]] - Recovery Services Vault to be created or updated
111
- x_ms_authorization_auxiliary: Optional[str] - Additional authorization header
112
113
Returns:
114
LROPoller[Vault]: Long-running operation poller returning the created/updated vault
115
"""
116
```
117
118
**Usage Example:**
119
120
```python
121
from azure.mgmt.recoveryservices.models import Vault, Sku, SkuName, IdentityData, ResourceIdentityType
122
123
# Create a new vault with system-assigned identity
124
new_vault = Vault(
125
location="eastus",
126
sku=Sku(name=SkuName.STANDARD),
127
identity=IdentityData(type=ResourceIdentityType.SYSTEM_ASSIGNED),
128
tags={"Environment": "Production", "Department": "IT"}
129
)
130
131
# Start creation operation
132
operation = client.vaults.begin_create_or_update(
133
"my-resource-group",
134
"my-new-vault",
135
new_vault
136
)
137
138
# Wait for completion
139
created_vault = operation.result()
140
print(f"Created vault: {created_vault.name}")
141
print(f"Vault ID: {created_vault.id}")
142
```
143
144
### Update Vault
145
146
Updates properties of an existing Recovery Services vault. This is a long-running operation.
147
148
```python { .api }
149
def begin_update(
150
resource_group_name: str,
151
vault_name: str,
152
vault: Union[PatchVault, IO[bytes]],
153
x_ms_authorization_auxiliary: Optional[str] = None,
154
**kwargs
155
) -> LROPoller[Vault]:
156
"""
157
Updates the vault.
158
159
Parameters:
160
- resource_group_name: str - The name of the resource group
161
- vault_name: str - The name of the recovery services vault
162
- vault: Union[PatchVault, IO[bytes]] - Recovery Services Vault patch request
163
- x_ms_authorization_auxiliary: Optional[str] - Additional authorization header
164
165
Returns:
166
LROPoller[Vault]: Long-running operation poller returning the updated vault
167
"""
168
```
169
170
**Usage Example:**
171
172
```python
173
from azure.mgmt.recoveryservices.models import PatchVault, IdentityData, ResourceIdentityType
174
175
# Update vault to add user-assigned identity
176
patch_vault = PatchVault(
177
identity=IdentityData(
178
type=ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED,
179
user_assigned_identities={
180
"/subscriptions/.../resourceGroups/.../providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-identity": {}
181
}
182
),
183
tags={"Updated": "true"}
184
)
185
186
# Start update operation
187
operation = client.vaults.begin_update(
188
"my-resource-group",
189
"my-vault",
190
patch_vault
191
)
192
193
updated_vault = operation.result()
194
print(f"Updated vault identity: {updated_vault.identity.type}")
195
```
196
197
### Delete Vault
198
199
Deletes a Recovery Services vault. This is a long-running operation that permanently removes the vault and all associated data.
200
201
```python { .api }
202
def begin_delete(resource_group_name: str, vault_name: str, **kwargs) -> LROPoller[None]:
203
"""
204
Deletes a vault.
205
206
Parameters:
207
- resource_group_name: str - The name of the resource group
208
- vault_name: str - The name of the recovery services vault
209
210
Returns:
211
LROPoller[None]: Long-running operation poller
212
"""
213
```
214
215
**Usage Example:**
216
217
```python
218
# Delete a vault (WARNING: This permanently deletes the vault)
219
operation = client.vaults.begin_delete("my-resource-group", "vault-to-delete")
220
221
# Wait for deletion to complete
222
operation.result()
223
print("Vault deleted successfully")
224
225
# Check deletion status without waiting
226
if not operation.done():
227
print("Deletion in progress...")
228
else:
229
print("Deletion completed")
230
```
231
232
## Related Types
233
234
### Vault Configuration
235
236
```python { .api }
237
class VaultProperties:
238
"""
239
Properties of the vault.
240
241
Parameters:
242
- private_endpoint_state_for_backup: Optional[VaultPrivateEndpointState] - Private endpoint state for backup
243
- private_endpoint_state_for_site_recovery: Optional[VaultPrivateEndpointState] - Private endpoint state for site recovery
244
- private_endpoint_connections: Optional[List[PrivateEndpointConnection]] - List of private endpoint connections
245
- provisioning_state: Optional[str] - Provisioning State
246
- upgrade_details: Optional[UpgradeDetails] - Details for upgrading vaults
247
- public_network_access: Optional[PublicNetworkAccess] - Public network access setting
248
- monitoring_settings: Optional[MonitoringSettings] - Monitoring settings
249
- encryption: Optional[VaultPropertiesEncryption] - Customer Managed Key details
250
- move_details: Optional[VaultPropertiesMoveDetails] - Move details
251
- backup_storage_version: Optional[BackupStorageVersion] - Backup storage version
252
- redundancy_settings: Optional[VaultPropertiesRedundancySettings] - Redundancy settings
253
- security_settings: Optional[SecuritySettings] - Security settings
254
- bcdr_security_level: Optional[BCDRSecurityLevel] - Security level for BCDR
255
- restore_settings: Optional[RestoreSettings] - Restore settings
256
"""
257
```
258
259
### Patch Operations
260
261
```python { .api }
262
class PatchVault(PatchTrackedResource):
263
"""
264
Patch Resource information for Vault.
265
266
Parameters:
267
- tags: Optional[Dict[str, str]] - Resource tags
268
- location: Optional[str] - Resource location
269
- identity: Optional[IdentityData] - Managed service identity
270
- properties: Optional[VaultProperties] - Properties of the vault
271
- sku: Optional[Sku] - Identifies the unique system identifier for each Azure resource
272
"""
273
```
274
275
### Long-Running Operations
276
277
```python { .api }
278
class LROPoller:
279
"""
280
Long-running operation poller.
281
282
Methods:
283
- result(timeout: Optional[int] = None) -> T - Get the final result, waiting if necessary
284
- done() -> bool - Check if the operation is complete
285
- status() -> str - Get current operation status
286
- wait(timeout: Optional[int] = None) -> None - Wait for operation completion
287
"""
288
```