Alright guys, I fixed it by building the docker myself, creating an azure container registry and pushing it over my existing azure web app (I first tried it with a new one). Note: You must have VNET and your database set up properly to get this running, also a understanding of docker is required but I try to be as detailed in this post as I can. Here is what I did:
- I created a dockerfile on the root level of my django app. Note: The Django_Settings_Module is specifically set to the settings I want to use in my docker, this might differ in your setup. Same goes for the requirements.txt location as it is also in my root directory. Make sure to test it with your local settings first before proceeding.
FROM python:3.9
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV DJANGO_SETTINGS_MODULE=config.settings.production
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Make port 8000 available to the world outside this container
EXPOSE 8000
# Run Gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--timeout", "120", "--workers", "4", "--log-level", "debug", "config.wsgi:application"]
- I logged in to azure with the command "az login" then I created an Azure Container Registry to push my container to, so it can be pulled from my webapp (from https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-azure-cli)
az acr create --resource-group myResourceGroup \
--name mycontainerregistry --sku Basic
- I now can build my docker (remember to test it locally first):
docker build -t app .
- You now need to docker tag my created docker with its version to the created ACR
docker tag app mycontainerregistry.azurecr.io/app:latest
- Login to you ACR
az acr login --name mycontainerregistry
and push your docker docker push
mycontainerregistry.azurecr.io/app:latest
6. At this point you could create a new service plan or just use our old one
New: az appservice plan create --name NewAppService --resource-group ExistignRessourceGroup --is-linux --sku B1 --location YourLocation
location names for the CLI can be found here: https://azuretracks.com/2021/04/current-azure-region-names-reference/
- Now you create the webapp, I first created a new webApp to test if everythings running. Note:
- I use a flexible prostgres database on azure, so it is very important, that my web app is on the same plan as my database to ensure they can be in the same (sub)vnet.
- after I tested my container with a new app, I overwrote my existing app (DANGER, Dont overwrite anything if you did not test the new app fully etc.,)
az webapp create --resource-group NewOrExistingRG --plan NewOrExistingPlan --name NewOrExistingApp --deployment-container-image-name mycontainerregistry.azurecr.io/app:latest
- After this you need to find your credentials for the app to set them properly
az acr credential show --name mycontainerregistry
Configure the container
az webapp config container set --name App--resource-group RG --docker-custom-image-name mycontainerregistry.azurecr.io/app:latest --docker-registry-server-url https://mycontainerregistry.azurecr.io --docker-registry-server-user mycontainerregistry --docker-registry-server-password GeneratedPassword
Lastly, you need get to remove your startup command, as it is set in the docker and find "Networking" in your App, find the "Outbound traffic configuration" and click on "not configured". There should be your Subnet to enable a communication with you database
This is the process to get your App back to live, everything works for my. Note: This completelly excludes any Git Workflows and is simply a workaround for now! As my app runs in productive with mutliple companies accessing it, it was important to find a quick solution for this mess.
I hope this helps someone.
DrBash