skip to Main Content

I have a containerised Django Rest Framework application along with a Celery container for background task processing and Redis container as a broker.

I want to deploy this application to the Azure Serverless. I have been trying to look for the solutions but had no luck so far.

Here are the two question I have –

  1. Is it possible to deploy multi-container group application to Azure Serverless?

  2. Is it possible to deploy the tech stack I have stated above to Azure Serverless? (please provide an example or a link to the documentation to guide me.)

Project’s Docker Configurations –

docker-compose

version: "3"

services:

  redis:
    container_name: redis-container
    image: "redis:latest"
    ports: 
      - "6379:6379"
    restart: always
    command: "redis-server"

  snowflake-optimizer:
    container_name: snowflake-optimizer
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/snowflake-backend
    ports:
      - "80:80"
    expose:
        - "80"
    restart: always
    command: "python manage.py runserver 0.0.0.0:80"
    links: 
      - redis

    
  celery:
    container_name: celery-container
    build: 
      context: .
      dockerfile: Dockerfile.celery
    command: "celery  -A snowflake_optimizer worker -l INFO"
    volumes:
      - .:/snowflake-optimizer
    restart: always
    links:
      - redis
    depends_on: 
      - snowflake-optimizer
  

Dockerfile (Django Rest Framework)

FROM python:3.7-slim

ENV PYTHONUNBUFFERED 1

RUN apt-get update &&
    apt-get install python3-dev default-libmysqlclient-dev gcc  -y &&
    apt-get install -y libssl-dev libffi-dev &&
    python -m pip install --upgrade pip &&
    mkdir /snowflake-backend

WORKDIR /snowflake-backend

COPY ./requirements.txt /requirements.txt

COPY . /snowflake-backend

EXPOSE 80

RUN pip install -r /requirements.txt

RUN pip install -U "celery[redis]"

RUN python manage.py makemigrations &&
    python manage.py migrate
    
CMD [ "python", "manage.py", "runserver", "0.0.0.0:80"]

Docker.celery (Celery)

FROM python:3.7-slim

ENV PYTHONUNBUFFERED 1

RUN apt-get update &&
    apt-get install python3-dev default-libmysqlclient-dev gcc  -y &&
    apt-get install -y libssl-dev libffi-dev &&
    python -m pip install --upgrade pip &&
    mkdir /snowflake-backend

WORKDIR /snowflake-backend

COPY ./requirements.txt /requirements.txt

COPY . /snowflake-backend

EXPOSE 80


RUN pip install -r /requirements.txt

RUN pip install -U "celery[redis]"

CMD [ "celery", "-A", "snowflake_optimizer", "worker", "-l ", "INFO"]

2

Answers


  1. To deploy a multi-container app on Azure Containers Instances using a Docker Compose file using the Azure CLI:

    az container create --resource-group myResourceGroup --file docker-compose.yaml
    

    Documentation

    You can also use the docker-compose CLI directly.

    Documentation

    Login or Signup to reply.
  2. The questions is what do we mean here by Azure Serverless. Usually people associate serverless with serverless functions. As of 2020 November, Azure Functions do not support Docker deployment, at least not in a way to be able to deploy a Django application.

    Understandably there are other options to be able to deploy containers into Azure:

    1. Azure Container Instances: they do support multi-container deployments. The container orchestration is limited and you get billed by second.
    2. Azure WebApp: it has a preview feature for support for multi-container deployments. Since it is in preview, the pricing may change and there is not much information about orchestration. I think this will be the recommended approach for the deployment described in your question, I would give this a try.
    3. AKS – Azure Kubernetes Service: this should be used for serious production workloads, obviously it requires Kubernetes knowledge which may be a huge overhead for a momentary simple deployment.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search