{"id":1380,"library":"azure-mgmt-redis","title":"Azure Redis Cache Management","description":"The azure-mgmt-redis client library provides functionality to manage Azure Redis Cache instances, including creation, update, deletion, and scaling. It is part of the Azure SDK for Python, currently at version 14.5.0, and follows a continuous release cadence for bug fixes and new features, with major versions introducing breaking changes.","status":"active","version":"14.5.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/redis/azure-mgmt-redis","tags":["azure","redis","cloud","management","microsoft"],"install":[{"cmd":"pip install azure-mgmt-redis azure-identity","lang":"bash","label":"Install package and authentication library"}],"dependencies":[{"reason":"Required for authenticating to Azure services using modern credential types like DefaultAzureCredential.","package":"azure-identity","optional":false},{"reason":"Provides shared core functionality, including transport pipelines, exceptions, and data models.","package":"azure-core","optional":false}],"imports":[{"note":"Older versions or incorrect module paths might lead to `ImportError`. Always use the direct package import.","wrong":"from azure.mgmt.redis.rediscachemanagementclient import RedisCacheManagementClient","symbol":"RedisManagementClient","correct":"from azure.mgmt.redis import RedisManagementClient"},{"note":"This is the recommended way to authenticate in modern Azure SDKs, supporting various authentication flows.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.redis import RedisManagementClient\n\n# Set your Azure Subscription ID as an environment variable (e.g., AZURE_SUBSCRIPTION_ID)\n# Or replace os.environ.get with your actual subscription ID.\nsubscription_id = os.environ.get('AZURE_SUBSCRIPTION_ID', 'YOUR_SUBSCRIPTION_ID')\n\n# Authenticate using DefaultAzureCredential\n# This will try to authenticate using various methods, e.g., environment variables, managed identity, Azure CLI, Visual Studio Code.\ncredential = DefaultAzureCredential()\n\n# Create a RedisManagementClient\nredis_client = RedisManagementClient(credential, subscription_id)\n\nprint(f\"Listing Redis Caches in subscription {subscription_id}:\")\n\n# List all Redis Caches in the subscription\n# Operations like .list_by_subscription() return an iterator for paginated results.\ntry:\n    for cache in redis_client.redis.list_by_subscription():\n        print(f\"  - Name: {cache.name}, Location: {cache.location}, SKU: {cache.sku.name}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure, create a `RedisManagementClient`, and then list all Azure Redis Cache instances within a given subscription. Ensure you have set `AZURE_SUBSCRIPTION_ID` and other Azure authentication environment variables (e.g., for service principal) or are logged in via Azure CLI/VS Code."},"warnings":[{"fix":"For versions 8.0.0 and later, clients are instantiated with `credential` (e.g., `DefaultAzureCredential`) and `subscription_id` directly, following the pattern `RedisManagementClient(credential, subscription_id)`. Older versions used different authentication objects and client constructors.","message":"Breaking changes were introduced in `azure-mgmt-redis` version 8.0.0 due to alignment with the new Azure SDK guidelines. This involved significant changes to client constructor signatures and model names.","severity":"breaking","affected_versions":"<8.0.0"},{"fix":"Iterate directly over the returned object (e.g., `for cache in client.redis.list_by_subscription():`). If a list is absolutely needed, explicitly convert it: `list_of_caches = list(client.redis.list_by_subscription())`.","message":"List operations (e.g., `list_by_subscription`, `list_by_resource_group`) return iterable objects (an Azure Pager) for paginated results, not standard Python lists.","severity":"gotcha","affected_versions":"All versions >=8.0.0"},{"fix":"Update `try...except` blocks to catch `HttpResponseError` from `azure.core.exceptions` for API-related errors. Example: `from azure.core.exceptions import HttpResponseError`.","message":"Exception handling for Azure SDK clients changed from `msrestazure.azure_exceptions.CloudError` to `azure.core.exceptions.HttpResponseError` when the SDK moved to `azure-core`.","severity":"breaking","affected_versions":"<8.0.0"},{"fix":"Always ensure the `resource_group_name` parameter is correctly provided when interacting with resources within a specific resource group. Example: `redis_client.redis.get(resource_group_name, redis_cache_name)`.","message":"Many Azure management operations, especially for existing resources, require a specific resource group name. Failing to provide it will result in an error or incorrect operation.","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"}