Search code examples
pythondjangoazureazure-web-app-servicedjango-channels

Django channels and azure


I am trying to deploy django channels in azure.

I have already integrated it with azure redis cache and it's working good in local host.

I have tried the normal deployment of django apps in azure, everything except sockets are working.

CHANNEL_LAYERS = {
'default': {
    'BACKEND': 'channels_redis.core.RedisChannelLayer',
    'CONFIG': {
        "hosts": [(f'redis://:{os.environ["REDISPASS"]}@mywebsite.redis.cache.windows.net:6379/0')],
    },
},

}

It's showing unexpected error website closed unexpectedly.

I have followed this basic stater code for implementing django channels.

Tutorial


Solution

  • From your config file, I saw you use port 6379.

    This doesn't work, you can only use https port 443 and http port 80 in the azure webapp service.

    If you must use a custom port such as 6379, it is recommended to use a server and open a secure port, then the webapp will not be deployed on azure.