2

I'm trying to move my Django application from Heroku to Azure app service.

The Application is consists of Websocket and Rest API.

So the Web part of the application is running on a daphne web server and worker part is running on celery.

In Heroku, my Procfile looks like

web: daphne backend.asgi:application --port $PORT --bind 0.0.0.0 -v 0
worker: celery worker -A backend --loglevel=debug --concurrency=8

When I tried the same on Azure Application service, They are providing a single startup command to start the server after build.

I have web and worker commands to run the server. I tried to use a sh file to execute the Web and worker commands. But it won't work

So below are the issues I'm facing

  1. Daphne server command is not working in azure but when I changed it to gunicorn it works [ but no WebSocket support :( by using gunicorn ]
  2. Also, I don't know how to run web and worker in azure app service because they have only one startup command option

Any help or guidance is welcome

Thanks in advance.....

Muthu Kumar
  • 885
  • 2
  • 14
  • 25

1 Answers1

2

I got the solution by just using basic DockerFile with a simple & option. I have attached the custom DockerFile I used in azure

FROM python:3.7
RUN mkdir -p /opt/services/app/src
WORKDIR /opt/services/app/src
ADD . /opt/services/app/src
RUN pip install -r requirements.txt
EXPOSE 8000
CMD python manage.py collectstatic --no-input
CMD python manage.py migrate
CMD daphne backend.asgi:application --port 8000 --bind 0.0.0.0 -v 0 & celery worker -A backend --loglevel=debug --concurrency=8
Muthu Kumar
  • 885
  • 2
  • 14
  • 25