0
# Client Management
1
2
Core client initialization and configuration for both ActiveStamp and PassiveStamp APIs. The Azure Recovery Services Backup library provides separate clients optimized for different backup scenarios and operational patterns.
3
4
## Capabilities
5
6
### ActiveStamp Client
7
8
Primary client for comprehensive backup management operations including policy management, protection configuration, backup execution, and standard restore operations.
9
10
```python { .api }
11
class RecoveryServicesBackupClient:
12
def __init__(
13
self,
14
credential: TokenCredential,
15
subscription_id: str,
16
base_url: str = "https://management.azure.com",
17
**kwargs
18
):
19
"""
20
Initialize the ActiveStamp backup client.
21
22
Parameters:
23
- credential: Azure credential for authentication
24
- subscription_id: Azure subscription ID
25
- base_url: Azure management endpoint URL
26
- kwargs: Additional client configuration options
27
"""
28
29
# Primary operation groups (43 total)
30
backup_engines: BackupEnginesOperations
31
backup_jobs: BackupJobsOperations
32
backup_operation_results: BackupOperationResultsOperations
33
backup_operation_statuses: BackupOperationStatusesOperations
34
backup_policies: BackupPoliciesOperations
35
backup_protectable_items: BackupProtectableItemsOperations
36
backup_protected_items: BackupProtectedItemsOperations
37
backup_protection_containers: BackupProtectionContainersOperations
38
backup_protection_intent: BackupProtectionIntentOperations
39
backup_resource_encryption_configs: BackupResourceEncryptionConfigsOperations
40
backup_resource_storage_configs_non_crr: BackupResourceStorageConfigsNonCRROperations
41
backup_resource_vault_configs: BackupResourceVaultConfigsOperations
42
backup_status: BackupStatusOperations
43
backup_usage_summaries: BackupUsageSummariesOperations
44
backup_workload_items: BackupWorkloadItemsOperations
45
backups: BackupsOperations
46
backup_resource_storage_configs: BackupResourceStorageConfigsOperations
47
cross_region_restore: CrossRegionRestoreOperations
48
deleted_protection_containers: DeletedProtectionContainersOperations
49
export_jobs_operation_results: ExportJobsOperationResultsOperations
50
feature_support: FeatureSupportOperations
51
item_level_recovery_connections: ItemLevelRecoveryConnectionsOperations
52
job_cancellations: JobCancellationsOperations
53
job_details: JobDetailsOperations
54
job_operation_results: JobOperationResultsOperations
55
jobs: JobsOperations
56
operations: OperationsOperations
57
private_endpoint_connection: PrivateEndpointConnectionOperations
58
private_endpoint: PrivateEndpointOperations
59
protected_item_operation_results: ProtectedItemOperationResultsOperations
60
protected_item_operation_statuses: ProtectedItemOperationStatusesOperations
61
protected_items: ProtectedItemsOperations
62
protection_container_operation_results: ProtectionContainerOperationResultsOperations
63
protection_container_refresh_operation_results: ProtectionContainerRefreshOperationResultsOperations
64
protection_containers: ProtectionContainersOperations
65
protection_intent: ProtectionIntentOperations
66
protection_policies: ProtectionPoliciesOperations
67
protection_policy_operation_results: ProtectionPolicyOperationResultsOperations
68
protection_policy_operation_statuses: ProtectionPolicyOperationStatusesOperations
69
recovery_points: RecoveryPointsOperations
70
restores: RestoresOperations
71
security_pins: SecurityPINsOperations
72
soft_deleted_containers: SoftDeletedContainersOperations
73
validate_operation: ValidateOperationOperations
74
validate_operation_results: ValidateOperationResultsOperations
75
validate_operation_statuses: ValidateOperationStatusesOperations
76
77
def close(self) -> None:
78
"""Close the client and release resources."""
79
```
80
81
Usage example:
82
83
```python
84
import os
85
from azure.identity import DefaultAzureCredential
86
from azure.mgmt.recoveryservicesbackup.activestamp import RecoveryServicesBackupClient
87
88
# Create client with default authentication
89
credential = DefaultAzureCredential()
90
subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")
91
92
client = RecoveryServicesBackupClient(
93
credential=credential,
94
subscription_id=subscription_id
95
)
96
97
# Use the client for backup operations
98
policies = client.backup_policies.list("my-rg", "my-vault")
99
```
100
101
### PassiveStamp Client
102
103
Specialized client for Cross-Region Restore (CRR) operations, optimized for disaster recovery scenarios and cross-region backup management.
104
105
```python { .api }
106
class RecoveryServicesBackupPassiveClient:
107
def __init__(
108
self,
109
credential: TokenCredential,
110
subscription_id: str,
111
base_url: str = "https://management.azure.com",
112
**kwargs
113
):
114
"""
115
Initialize the PassiveStamp backup client for CRR operations.
116
117
Parameters:
118
- credential: Azure credential for authentication
119
- subscription_id: Azure subscription ID
120
- base_url: Azure management endpoint URL
121
- kwargs: Additional client configuration options
122
"""
123
124
# CRR-specific operation groups (11 total)
125
backup_crr_job_details: BackupCrrJobDetailsOperations
126
backup_crr_jobs: BackupCrrJobsOperations
127
backup_crr_operation_results: BackupCrrOperationResultsOperations
128
crr_operation_status: CrrOperationStatusOperations
129
cross_region_restore: CrossRegionRestoreOperations
130
recovery_points: RecoveryPointsOperations
131
recovery_points_get: RecoveryPointsGetOperations
132
recovery_points_crr: RecoveryPointsCrrOperations
133
restores: RestoresOperations
134
validate_operations: ValidateOperationsOperations
135
136
def close(self) -> None:
137
"""Close the client and release resources."""
138
```
139
140
Usage example:
141
142
```python
143
from azure.mgmt.recoveryservicesbackup.passivestamp import RecoveryServicesBackupPassiveClient
144
145
# Create CRR client
146
crr_client = RecoveryServicesBackupPassiveClient(
147
credential=credential,
148
subscription_id=subscription_id
149
)
150
151
# Use for cross-region restore operations
152
crr_jobs = crr_client.backup_crr_jobs.list("eastus", "my-rg", "my-vault")
153
```
154
155
### Asynchronous Clients
156
157
Both ActiveStamp and PassiveStamp clients provide asynchronous versions for high-performance async/await operations.
158
159
```python { .api }
160
from azure.mgmt.recoveryservicesbackup.activestamp.aio import RecoveryServicesBackupClient as AsyncActiveClient
161
from azure.mgmt.recoveryservicesbackup.passivestamp.aio import RecoveryServicesBackupPassiveClient as AsyncPassiveClient
162
163
class AsyncActiveClient:
164
def __init__(
165
self,
166
credential: AsyncTokenCredential,
167
subscription_id: str,
168
base_url: str = "https://management.azure.com",
169
**kwargs
170
): ...
171
172
async def close(self) -> None:
173
"""Close the async client and release resources."""
174
175
class AsyncPassiveClient:
176
def __init__(
177
self,
178
credential: AsyncTokenCredential,
179
subscription_id: str,
180
base_url: str = "https://management.azure.com",
181
**kwargs
182
): ...
183
184
async def close(self) -> None:
185
"""Close the async client and release resources."""
186
```
187
188
Usage example:
189
190
```python
191
import asyncio
192
from azure.identity.aio import DefaultAzureCredential
193
from azure.mgmt.recoveryservicesbackup.activestamp.aio import RecoveryServicesBackupClient
194
195
async def main():
196
credential = DefaultAzureCredential()
197
client = RecoveryServicesBackupClient(
198
credential=credential,
199
subscription_id=subscription_id
200
)
201
202
try:
203
policies = []
204
async for policy in client.backup_policies.list("my-rg", "my-vault"):
205
policies.append(policy)
206
finally:
207
await client.close()
208
209
asyncio.run(main())
210
```
211
212
### Authentication
213
214
All clients support multiple authentication methods through the Azure Identity library.
215
216
```python { .api }
217
# Environment-based authentication (recommended)
218
from azure.identity import DefaultAzureCredential
219
credential = DefaultAzureCredential()
220
221
# Service principal authentication
222
from azure.identity import ClientSecretCredential
223
credential = ClientSecretCredential(
224
tenant_id="your-tenant-id",
225
client_id="your-client-id",
226
client_secret="your-client-secret"
227
)
228
229
# Managed identity authentication
230
from azure.identity import ManagedIdentityCredential
231
credential = ManagedIdentityCredential()
232
233
# Interactive browser authentication
234
from azure.identity import InteractiveBrowserCredential
235
credential = InteractiveBrowserCredential()
236
```
237
238
### Configuration Options
239
240
Clients support various configuration options for customization and optimization.
241
242
```python { .api }
243
from azure.core.credentials import TokenCredential
244
from azure.core.pipeline.policies import RetryPolicy
245
246
client = RecoveryServicesBackupClient(
247
credential=credential,
248
subscription_id=subscription_id,
249
base_url="https://management.azure.com",
250
# Custom retry policy
251
retry_policy=RetryPolicy(retry_total=5),
252
# Request timeout
253
timeout=300,
254
# Custom headers
255
headers={"User-Agent": "MyApp/1.0"},
256
# Logging level
257
logging_enable=True,
258
# Connection pool settings
259
connection_pool_size=20
260
)
261
```
262
263
## Types
264
265
```python { .api }
266
from azure.core.credentials import TokenCredential
267
268
# For async clients
269
from azure.core.credentials_async import AsyncTokenCredential
270
271
# Client configuration types
272
ClientConfiguration = Dict[str, Any]
273
```