0
# Azure Recovery Services
1
2
Microsoft Azure Recovery Services Client Library for Python provides comprehensive APIs for managing Azure Recovery Services vaults, backup and disaster recovery operations, certificates, private endpoints, and usage monitoring. This library enables programmatic access to Azure's recovery services capabilities including vault management, backup policy configuration, and recovery operations.
3
4
## Package Information
5
6
- **Package Name**: azure-mgmt-recoveryservices
7
- **Language**: Python
8
- **Installation**: `pip install azure-mgmt-recoveryservices azure-identity`
9
10
## Core Imports
11
12
```python
13
from azure.mgmt.recoveryservices import RecoveryServicesClient
14
from azure.identity import DefaultAzureCredential
15
```
16
17
For models and types:
18
19
```python
20
from typing import Optional, Union, List, Dict, IO
21
from azure.core.polling import LROPoller
22
from azure.core.paging import ItemPaged
23
from azure.mgmt.recoveryservices.models import (
24
Vault, VaultProperties, Sku, SkuName, IdentityData,
25
ResourceIdentityType, PatchVault, VaultUsage, ReplicationUsage,
26
CertificateRequest, VaultCertificateResponse, PrivateLinkResource,
27
VaultExtendedInfoResource, CheckNameAvailabilityParameters,
28
CheckNameAvailabilityResult, ResourceCapabilities, CapabilitiesResponse
29
)
30
```
31
32
## Basic Usage
33
34
```python
35
import os
36
from azure.identity import DefaultAzureCredential
37
from azure.mgmt.recoveryservices import RecoveryServicesClient
38
39
# Initialize client with default credential
40
credential = DefaultAzureCredential()
41
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"]
42
client = RecoveryServicesClient(credential, subscription_id)
43
44
# List all Recovery Services vaults in subscription
45
vaults = client.vaults.list_by_subscription_id()
46
for vault in vaults:
47
print(f"Vault: {vault.name}, Location: {vault.location}")
48
49
# Get a specific vault
50
resource_group = "my-resource-group"
51
vault_name = "my-recovery-vault"
52
vault = client.vaults.get(resource_group, vault_name)
53
print(f"Vault SKU: {vault.sku.name}")
54
55
# Create a new vault
56
from azure.mgmt.recoveryservices.models import Vault, Sku, SkuName
57
58
new_vault = Vault(
59
location="eastus",
60
sku=Sku(name=SkuName.STANDARD)
61
)
62
63
create_operation = client.vaults.begin_create_or_update(
64
resource_group, "new-vault", new_vault
65
)
66
created_vault = create_operation.result()
67
print(f"Created vault: {created_vault.name}")
68
```
69
70
## Architecture
71
72
The Azure Recovery Services client follows Azure's standard management SDK patterns:
73
74
- **RecoveryServicesClient**: Main client class providing access to all service operations
75
- **Operations Groups**: Specialized operation classes for different service areas (vaults, certificates, etc.)
76
- **Models**: Data transfer objects representing Azure resources and configuration
77
- **Long-Running Operations**: Asynchronous operations using the LROPoller pattern
78
- **Authentication**: Integration with Azure Identity for credential management
79
80
The library provides both synchronous and asynchronous versions of all operations, following Azure SDK design guidelines for consistent error handling, logging, and authentication across all Azure services.
81
82
## Capabilities
83
84
### Vault Management
85
86
Core functionality for creating, updating, deleting, and querying Recovery Services vaults. Includes support for vault properties, SKU configuration, identity management, and resource lifecycle operations.
87
88
```python { .api }
89
def list_by_subscription_id(**kwargs) -> ItemPaged[Vault]: ...
90
def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[Vault]: ...
91
def get(resource_group_name: str, vault_name: str, **kwargs) -> Vault: ...
92
def begin_create_or_update(resource_group_name: str, vault_name: str, vault: Union[Vault, IO[bytes]], x_ms_authorization_auxiliary: Optional[str] = None, **kwargs) -> LROPoller[Vault]: ...
93
def begin_delete(resource_group_name: str, vault_name: str, **kwargs) -> LROPoller[None]: ...
94
def begin_update(resource_group_name: str, vault_name: str, vault: Union[PatchVault, IO[bytes]], x_ms_authorization_auxiliary: Optional[str] = None, **kwargs) -> LROPoller[Vault]: ...
95
```
96
97
[Vault Management](./vault-management.md)
98
99
### Certificate Management
100
101
Operations for uploading and managing certificates for Recovery Services vaults, enabling secure communication and authentication for backup and recovery operations.
102
103
```python { .api }
104
def create(resource_group_name: str, vault_name: str, certificate_name: str, certificate_request: Union[CertificateRequest, IO[bytes]], **kwargs) -> VaultCertificateResponse: ...
105
```
106
107
[Certificate Management](./certificate-management.md)
108
109
### Private Link Resources
110
111
Management of private endpoint connections and private link resources for secure, private connectivity to Recovery Services vaults over Azure's backbone network.
112
113
```python { .api }
114
def list(resource_group_name: str, vault_name: str, **kwargs) -> ItemPaged[PrivateLinkResource]: ...
115
def get(resource_group_name: str, vault_name: str, private_link_resource_name: str, **kwargs) -> PrivateLinkResource: ...
116
```
117
118
[Private Link Resources](./private-link-resources.md)
119
120
### Usage Monitoring
121
122
Monitoring and reporting capabilities for vault usage metrics, replication usage statistics, and capacity planning information.
123
124
```python { .api }
125
def list_by_vaults(resource_group_name: str, vault_name: str, **kwargs) -> ItemPaged[VaultUsage]: ...
126
def list(resource_group_name: str, vault_name: str, **kwargs) -> ItemPaged[ReplicationUsage]: ...
127
```
128
129
[Usage Monitoring](./usage-monitoring.md)
130
131
### Extended Vault Information
132
133
Management of additional vault metadata and extended configuration information beyond the core vault properties.
134
135
```python { .api }
136
def get(resource_group_name: str, vault_name: str, **kwargs) -> VaultExtendedInfoResource: ...
137
def create_or_update(resource_group_name: str, vault_name: str, resource_extended_info_details: Union[VaultExtendedInfoResource, IO[bytes]], **kwargs) -> VaultExtendedInfoResource: ...
138
def update(resource_group_name: str, vault_name: str, resource_extended_info_details: Union[VaultExtendedInfoResource, IO[bytes]], **kwargs) -> VaultExtendedInfoResource: ...
139
```
140
141
[Extended Vault Information](./extended-vault-info.md)
142
143
### Service Operations
144
145
Core service operations including name availability checking, service capability queries, identity management, and API operation discovery.
146
147
#### Recovery Services Operations
148
```python { .api }
149
def check_name_availability(resource_group_name: str, location: str, input: Union[CheckNameAvailabilityParameters, IO[bytes]], **kwargs) -> CheckNameAvailabilityResult: ...
150
def capabilities(location: str, input: Union[ResourceCapabilities, IO[bytes]], **kwargs) -> CapabilitiesResponse: ...
151
```
152
153
#### Registered Identities Operations
154
```python { .api }
155
def delete(resource_group_name: str, vault_name: str, identity_name: str, **kwargs) -> None: ...
156
```
157
158
#### Operations Discovery
159
```python { .api }
160
def list(**kwargs) -> ItemPaged[ClientDiscoveryValueForSingleApi]: ...
161
```
162
163
[Service Operations](./service-operations.md)
164
165
## Core Types
166
167
### Client Configuration
168
169
```python { .api }
170
class RecoveryServicesClient:
171
"""
172
Recovery Services Client.
173
174
Parameters:
175
- credential: TokenCredential - Credential needed for the client to connect to Azure
176
- subscription_id: str - The ID of the target subscription
177
- base_url: Optional[str] - Service URL
178
- api_version: str - Api Version (default: "2025-02-01")
179
- polling_interval: int - Default waiting time between two polls for LRO operations
180
"""
181
182
def __init__(self, credential: TokenCredential, subscription_id: str, base_url: Optional[str] = None, **kwargs): ...
183
def close(self) -> None: ...
184
def __enter__(self) -> Self: ...
185
def __exit__(self, *exc_details) -> None: ...
186
```
187
188
### Vault Resource Model
189
190
```python { .api }
191
class Vault(TrackedResource):
192
"""
193
Resource information, as returned by the resource provider.
194
195
Parameters:
196
- location: str - Resource location
197
- tags: Optional[Dict[str, str]] - Resource tags
198
- identity: Optional[IdentityData] - Managed service identity
199
- properties: Optional[VaultProperties] - Properties of the vault
200
- sku: Optional[Sku] - Identifies the unique system identifier for each Azure resource
201
- system_data: Optional[SystemData] - Metadata pertaining to creation and last modification
202
"""
203
```
204
205
### SKU Configuration
206
207
```python { .api }
208
class Sku:
209
"""
210
Identifies the unique system identifier for each Azure resource.
211
212
Parameters:
213
- name: Union[str, SkuName] - The Sku name (RS0, Standard)
214
- tier: Optional[str] - The Sku tier
215
- family: Optional[str] - The sku family
216
- size: Optional[str] - The sku size
217
- capacity: Optional[str] - The sku capacity
218
"""
219
220
class SkuName(str, Enum):
221
RS0 = "RS0"
222
STANDARD = "Standard"
223
```
224
225
### Identity Configuration
226
227
```python { .api }
228
class IdentityData:
229
"""
230
Identity for the resource.
231
232
Parameters:
233
- principal_id: Optional[str] - The principal ID of resource identity
234
- tenant_id: Optional[str] - The tenant ID of resource
235
- type: Union[str, ResourceIdentityType] - The identity type
236
- user_assigned_identities: Optional[Dict[str, UserIdentity]] - UserAssignedIdentities
237
"""
238
239
class ResourceIdentityType(str, Enum):
240
SYSTEM_ASSIGNED = "SystemAssigned"
241
USER_ASSIGNED = "UserAssigned"
242
SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned"
243
NONE = "None"
244
```
245
246
### Usage and Monitoring Models
247
248
```python { .api }
249
class VaultUsage:
250
"""
251
Vault usage information.
252
253
Parameters:
254
- unit: Optional[Union[str, UsagesUnit]] - Unit of the usage statistic
255
- quota_period: Optional[str] - Quota period of the usage statistic
256
- next_reset_time: Optional[datetime] - Next reset time of the usage statistic
257
- current_value: Optional[int] - Current value of the usage statistic
258
- limit: Optional[int] - Limit of the usage statistic
259
- name: Optional[NameInfo] - Name of the usage statistic
260
"""
261
262
class ReplicationUsage:
263
"""
264
Replication usage information.
265
266
Parameters:
267
- monitored_item_count: Optional[int] - Number of replication protected items
268
- protected_item_count: Optional[int] - Number of replication protected VMs
269
- recovery_plan_count: Optional[int] - Number of replication recovery plans
270
- registered_servers_count: Optional[int] - Number of servers registered to vault
271
- job_failure_count_in_day: Optional[int] - Number of replication jobs failed in a day
272
"""
273
274
class UsagesUnit(str, Enum):
275
COUNT = "Count"
276
BYTES = "Bytes"
277
SECONDS = "Seconds"
278
PERCENT = "Percent"
279
COUNT_PER_SECOND = "CountPerSecond"
280
BYTES_PER_SECOND = "BytesPerSecond"
281
282
class NameInfo:
283
"""
284
The name of the usage.
285
286
Parameters:
287
- value: Optional[str] - Value of the usage
288
- localized_value: Optional[str] - Localized value of the usage
289
"""
290
291
### Certificate Models
292
293
```python { .api }
294
class CertificateRequest:
295
"""
296
Certificate request for vault.
297
298
Parameters:
299
- properties: Optional[RawCertificateData] - Raw certificate data
300
"""
301
302
class VaultCertificateResponse:
303
"""
304
Certificate response for vault.
305
306
Parameters:
307
- name: Optional[str] - Certificate name
308
- type: Optional[str] - Certificate type
309
- id: Optional[str] - Certificate resource Id
310
- properties: Optional[ResourceCertificateDetails] - Certificate details
311
"""
312
313
class RawCertificateData:
314
"""
315
Raw certificate data.
316
317
Parameters:
318
- certificate: Optional[bytes] - The base64 encoded certificate raw data string
319
- auth_type: Optional[Union[str, AuthType]] - Authentication type
320
"""
321
```
322
323
### Private Link Models
324
325
```python { .api }
326
class PrivateLinkResource:
327
"""
328
Information of the private link resource.
329
330
Parameters:
331
- group_id: Optional[str] - e.g. f9ad6492-33d4-4690-9999-6bfd52a0d081 (Backup) or f9ad6492-33d4-4690-9999-6bfd52a0d082 (SiteRecovery)
332
- required_members: Optional[List[str]] - [BackupFabric, BackupProtection, BackupSecurityPin, VaultSettings]
333
- required_zone_names: Optional[List[str]] - The private link resource Private link DNS zone name
334
"""
335
```
336
337
### Extended Vault Info Models
338
339
```python { .api }
340
class VaultExtendedInfoResource:
341
"""
342
Vault extended information.
343
344
Parameters:
345
- integrity_key: Optional[str] - Integrity key
346
- encryption_key: Optional[str] - Encryption key
347
- encryption_key_thumbprint: Optional[str] - Encryption key thumbprint
348
- algorithm: Optional[str] - Algorithm for vault extended info
349
"""
350
```
351
352
### Service Operations Models
353
354
```python { .api }
355
class CheckNameAvailabilityParameters:
356
"""
357
Resource name availability input parameters.
358
359
Parameters:
360
- type: Optional[str] - The resource type
361
- name: Optional[str] - The resource name
362
"""
363
364
class CheckNameAvailabilityResult:
365
"""
366
Response for check name availability API.
367
368
Parameters:
369
- name_available: Optional[bool] - Gets a boolean value that indicates availability
370
- reason: Optional[str] - Gets the reason that a name is not available
371
- message: Optional[str] - Gets an error message explaining the reason value
372
"""
373
374
class ResourceCapabilities:
375
"""
376
Input to get capabilities API.
377
378
Parameters:
379
- type: str - Describes the Resource type
380
- properties: Optional[ResourceCapabilitiesBase] - Describes the Resource properties
381
"""
382
383
class CapabilitiesResponse:
384
"""
385
Response for get capabilities API.
386
387
Parameters:
388
- type: Optional[str] - Describes the Resource type
389
- properties: Optional[CapabilitiesResponseProperties] - Describes the Resource properties
390
"""
391
392
class ClientDiscoveryValueForSingleApi:
393
"""
394
Available operation details.
395
396
Parameters:
397
- name: Optional[str] - Name of the operation
398
- display: Optional[ClientDiscoveryDisplay] - Contains the localized display information
399
- origin: Optional[str] - The intended executor of the operation
400
- properties: Optional[ClientDiscoveryForProperties] - Properties of the operation
401
"""
402
```
403
404
## Exception Handling
405
406
The SDK uses standard Azure SDK exceptions for error handling:
407
408
```python
409
from azure.core.exceptions import (
410
ClientAuthenticationError,
411
HttpResponseError,
412
ResourceExistsError,
413
ResourceNotFoundError,
414
ResourceNotModifiedError
415
)
416
417
try:
418
vault = client.vaults.get("resource-group", "vault-name")
419
except ResourceNotFoundError:
420
print("Vault not found")
421
except ClientAuthenticationError:
422
print("Authentication failed")
423
except HttpResponseError as e:
424
print(f"HTTP error: {e.status_code} - {e.message}")
425
```