Complete the code to create a Redis client connection using Azure SDK.
from azure.identity import DefaultAzureCredential from azure.mgmt.redis import RedisManagementClient credential = DefaultAzureCredential() client = RedisManagementClient(credential, [1])
The RedisManagementClient requires the Azure subscription ID to connect to the correct Azure subscription.
Complete the code to retrieve the Redis cache keys from Azure.
keys = client.redis.list_keys([1], 'myRedisCache')
The first argument to list_keys is the resource_group_name to identify the Azure resource group.
Fix the error in the Redis command to set a key-value pair using redis-py client.
import redis r = redis.Redis(host='myredis.redis.cache.windows.net', port=6380, ssl=True, password='[1]') r.set('mykey', 'myvalue')
The Redis client requires the primary access key as the password to authenticate.
Fill both blanks to retrieve and decode a Redis key value.
value = r.get('mykey') if value is not None: decoded_value = value[1][2]
Redis returns bytes, so use .decode('utf-8') to convert to string.
Fill all three blanks to delete a Redis key and check if deletion was successful.
deleted_count = r.delete([1]) if deleted_count [2] 1: print([3])
Use r.delete('mykey') to delete the key, check if result equals 1, then print success message.