An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
It seems you are encountering issues with Redis clustering on your Azure Managed Redis instance. The redis.exceptions.MovedError indicates that your Redis client is trying to access a key that is not located on the current node, which is common in clustered setups. Here are some steps and considerations to help you troubleshoot and resolve the issue:
- Ensure Proper Clustering Configuration: Since Azure Managed Redis instances are clustered by default, make sure your Redis client is configured to handle clustering. In your case, the
redis-pylibrary should be set up to support clustering. You might need to use theClusterclass from theredis-py-clusterpackage instead of the standardredis.Redisclass. - Use the Correct Connection Parameters: When connecting to a clustered Redis instance, ensure you are using the correct hostname and port. The connection string should not include the port in the hostname. Instead, specify the port separately:
If you are using a clustered setup, consider switching to a client that supports the Redis Cluster API.self.redis = redis.Redis( host='<redacted>.eastus.redis.azure.net', port=10000, password=access_key, ssl=True ) - Testing with RedisInsight: If you are having trouble connecting with RedisInsight, ensure that you are not using the "Force standalone connection" option unless absolutely necessary. If you continue to see issues, check your network settings and ensure that the necessary ports are open and accessible.
- Check for Client Library Compatibility: Ensure that the version of the Redis client library you are using is compatible with the Redis Cluster API. If you are using an older version, consider upgrading to the latest version of the library.
- Review Azure Managed Redis Documentation: For more detailed guidance on using Azure Managed Redis and its clustering capabilities, refer to the official documentation. This can provide insights into best practices and configuration options.
By following these steps, you should be able to better manage your connection to the Azure Managed Redis instance and handle clustering more effectively.
References: