Registry /
azure / azure-mgmt-recoveryservices
Install & Compatibility
Where this runs
tested against v4.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.632s · 44.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 0.566s · 45MB
43MB installed
● package 43MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RecoveryServicesClient
✓ from azure.mgmt.recoveryservices import RecoveryServicesClient
DefaultAzureCredential
✓ from azure.identity import DefaultAzureCredential
Required for authentication with Azure services.
This quickstart demonstrates how to instantiate the `RecoveryServicesClient` using `DefaultAzureCredential` for authentication and then lists up to 5 Recovery Services vaults in the specified Azure subscription. Ensure `AZURE_SUBSCRIPTION_ID` is set as an environment variable or that `az login` has been executed.
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.recoveryservices import RecoveryServicesClient
# For local development, set environment variables:
# AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
# Alternatively, use `az login` via Azure CLI for interactive authentication.
# Acquire a credential object
credential = DefaultAzureCredential()
# Retrieve subscription ID from environment variable
# It is crucial to provide a valid subscription ID for client instantiation.
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
print("WARNING: AZURE_SUBSCRIPTION_ID environment variable not set. Please set it or ensure 'az login' is active.")
# Create the Recovery Services client
client = RecoveryServicesClient(credential, subscription_id)
print(f"Successfully created RecoveryServicesClient for subscription: {subscription_id}")
# Example: List up to 5 Recovery Services vaults in the subscription
try:
print("\nListing up to 5 Recovery Services vaults in the subscription...")
vault_count = 0
for vault in client.vaults.list_by_subscription():
print(f" - Vault Name: {vault.name}, Location: {vault.location}")
vault_count += 1
if vault_count >= 5:
break
if vault_count == 0:
print(" No Recovery Services vaults found in this subscription (or none in the first 5 pages).")
except Exception as e:
print(f"\nError listing vaults: {e}")
print(" Ensure you have 'Reader' or 'Recovery Services Contributor' permissions and AZURE_SUBSCRIPTION_ID is correct.")
Debug
Known issues
breakingThe `RecoveryServicesClient` constructor now requires `subscription_id` as the second argument.fixUpdate client instantiation from `RecoveryServicesClient(credential)` to `RecoveryServicesClient(credential, subscription_id)`.
affects: 4.0.0 and later (from 3.x)
breakingThere are significant API model changes and updates to operation signatures in various sub-clients (e.g., `BackupVaultOperationResults.get`, `RecoveryServices.get_operation_result`).fixConsult the official changelog and API reference for version 4.0.0 for specific resource models and updated operation signatures, especially if upgrading from a 3.x version.
affects: 4.0.0 and later (from 3.x)
gotchaAuthentication with Azure services requires the `azure-identity` library and proper credential setup. `DefaultAzureCredential` attempts various methods (environment variables, managed identity, Azure CLI, etc.).fixInstall `azure-identity` (`pip install azure-identity`). Set environment variables like `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET` for service principal authentication, or use `az login` for interactive user authentication.
affects: All versions
gotchaMany Azure Management operations are scoped to a specific resource group or subscription. Omitting or providing an incorrect scope will result in errors (e.g., 'ResourceNotFound' or 'Forbidden').fixAlways ensure the correct `subscription_id` is passed to the client constructor, and that `resource_group_name` is provided for operations that require it. Verify the principal used for authentication has appropriate permissions (e.g., 'Reader' or 'Recovery Services Contributor').
affects: All versions
Upgrade
Version history
4.2.0latest on PyPI · released Aug 17, 2026
Audit
Dependencies
azure-mgmt-corerequiredProvides core utilities and base classes for Azure management plane clients.
azure-identityoptionalRecommended for modern Azure authentication, including DefaultAzureCredential used in quickstarts.