{"id":1378,"library":"azure-mgmt-recoveryservices","title":"Azure Recovery Services Management","description":"The Microsoft Azure Recoveryservices Management Client Library for Python provides programmatic access to manage Azure Recovery Services vaults, backup policies, protected items, and disaster recovery configurations. It allows for automation of tasks like creating and configuring backup vaults, setting up replication, and managing backups. The current version is 4.0.0, and Azure SDKs generally follow an independent and frequent release cadence.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/recoveryservices/azure-mgmt-recoveryservices","tags":["azure","cloud","management","recoveryservices","backup","disaster-recovery","dr"],"install":[{"cmd":"pip install azure-mgmt-recoveryservices azure-identity","lang":"bash","label":"Install core library and authentication provider"}],"dependencies":[{"reason":"Provides core utilities and base classes for Azure management plane clients.","package":"azure-mgmt-core"},{"reason":"Recommended for modern Azure authentication, including DefaultAzureCredential used in quickstarts.","package":"azure-identity","optional":true}],"imports":[{"symbol":"RecoveryServicesClient","correct":"from azure.mgmt.recoveryservices import RecoveryServicesClient"},{"note":"Required for authentication with Azure services.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.recoveryservices import RecoveryServicesClient\n\n# For local development, set environment variables:\n# AZURE_SUBSCRIPTION_ID, AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET\n# Alternatively, use `az login` via Azure CLI for interactive authentication.\n\n# Acquire a credential object\ncredential = DefaultAzureCredential()\n\n# Retrieve subscription ID from environment variable\n# It is crucial to provide a valid subscription ID for client instantiation.\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"\")\n\nif not subscription_id:\n    print(\"WARNING: AZURE_SUBSCRIPTION_ID environment variable not set. Please set it or ensure 'az login' is active.\")\n\n# Create the Recovery Services client\nclient = RecoveryServicesClient(credential, subscription_id)\n\nprint(f\"Successfully created RecoveryServicesClient for subscription: {subscription_id}\")\n\n# Example: List up to 5 Recovery Services vaults in the subscription\ntry:\n    print(\"\\nListing up to 5 Recovery Services vaults in the subscription...\")\n    vault_count = 0\n    for vault in client.vaults.list_by_subscription():\n        print(f\"  - Vault Name: {vault.name}, Location: {vault.location}\")\n        vault_count += 1\n        if vault_count >= 5:\n            break\n    if vault_count == 0:\n        print(\"  No Recovery Services vaults found in this subscription (or none in the first 5 pages).\")\nexcept Exception as e:\n    print(f\"\\nError listing vaults: {e}\")\n    print(\"  Ensure you have 'Reader' or 'Recovery Services Contributor' permissions and AZURE_SUBSCRIPTION_ID is correct.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Update client instantiation from `RecoveryServicesClient(credential)` to `RecoveryServicesClient(credential, subscription_id)`.","message":"The `RecoveryServicesClient` constructor now requires `subscription_id` as the second argument.","severity":"breaking","affected_versions":"4.0.0 and later (from 3.x)"},{"fix":"Consult 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.","message":"There are significant API model changes and updates to operation signatures in various sub-clients (e.g., `BackupVaultOperationResults.get`, `RecoveryServices.get_operation_result`).","severity":"breaking","affected_versions":"4.0.0 and later (from 3.x)"},{"fix":"Install `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.","message":"Authentication with Azure services requires the `azure-identity` library and proper credential setup. `DefaultAzureCredential` attempts various methods (environment variables, managed identity, Azure CLI, etc.).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always 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').","message":"Many 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').","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}