How to persist Redis data in Azure Container Instances

M. Ebad Ullah Khan 5 Reputation points
2023-10-30T15:41:41.5666667+00:00

Hello,

I'm currently working with Azure Container Instances and the Azure Docker Registry to deploy a Redis image. The setup is working well, but I'm facing an issue with data persistence. Whenever the container instance restarts due to errors or other issues, all the data in my Redis instance is getting removed, which is not the behavior I want.

I've done some research and found that Redis can be configured to persist data by setting some fields in redis.conf file. I created a custom redis.conf file with the necessary configuration for data persistence. However, since I started using this custom redis.conf file, the Redis image no longer functions. No error logs are appearing on my local Docker desktop (even on the docker container instance), yet the Redis functionality remains non-functional.

I'm looking for guidance on how to properly configure Redis with a redis.conf file for data persistence while ensuring that the image remains operational. Any assistance or insights on what might be causing this issue would be greatly appreciated.

Thank you for your time and support.

Best regards,

Ebad Ullah

Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
221 questions
{count} vote

2 answers

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 27,977 Reputation points Microsoft Employee
    2023-10-30T19:17:38.8833333+00:00

    @M. Ebad Ullah Khan Welcome to Microsoft Q&A thanks for posting your question

    If you are looking for persisting data, you can always consider using the managed Azure Cache for Redis service in Azure. The distributed caching will be outside of the Azure Container instance and will have data persistent features built in. What is Azure Cache for Redis? - Azure Cache for Redis | Microsoft Learn

    Which docker image do you use for your container instance? How redis.conf file is used may depend on the docker image implementation. You can refer to Redis configuration | Redis for guidance.

    I hope this information helps

    Regards

    Geetha


  2. GeethaThatipatri-MSFT 27,977 Reputation points Microsoft Employee
    2023-11-27T17:41:25.5533333+00:00

    Hi @M. Ebad Ullah Khan

    As per the Support case , here is the resolution steps if this might also helps you.

    Yes, it is possible to deploy a Redis instance on AKS (Azure Kubernetes Service). You can use a Kubernetes manifest file to define the Redis deployment and service. The manifest file includes the necessary configuration for the Redis instance, such as the image and resource limits. Here is an example of a Kubernetes manifest file that deploys a Redis instance on AKS:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: azure-vote-back
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: azure-vote-back
      template:
        metadata:
          labels:
            app: azure-vote-back
        spec:
          nodeSelector:
            "kubernetes.io/os": linux
          containers:
          - name: azure-vote-back
            image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
            env:
            - name: ALLOW_EMPTY_PASSWORD
              value: "yes"
            resources:
              requests:
                cpu: 100m
                memory: 128Mi
              limits:
                cpu: 250m
                memory: 256Mi
            ports:
            - containerPort: 6379
              name: redis
    apiVersion: v1
    kind: Service
    metadata:
      name: azure-vote-back
    spec:
      ports:
      - port: 6379
      selector:
        app: azure-vote-back
    

    You can deploy the Redis instance using the kubectl apply command and specifying the name of the YAML manifest file:

    kubectl apply -f azure-vote.yaml
    

    This will create the necessary deployments and services for the Redis instance on AKS.

    0 comments No comments