Azure webapp fails during startup (it used to work before)

Thomas Elboth 10 Reputation points
2023-12-10T17:37:12.7433333+00:00

I have had an Azure webapp up and running the last couple of years.

It is basically Python code and fastAPI running a backend that I call from a separate website.

During this period I have updated the code sucessfully several times, and uploaded it to Azure.

Today, I made a few updates to the Python code, and then tried to redeploy the app.

The code is running fine, when I test it on my local computer. However, I was unable to get it back up on Azure...

My Dockerfile is given below:

FROM python:3.9.5

EXPOSE 2222 80 8000 22 8080

#not sure how many of these are needed....
RUN apt-get update && apt-get install -y \
  dos2unix \
  apt-utils \
  gcc \
  antiword \
  unixodbc-dev \
  odbcinst1debian2 \
  unixodbc \
  libodbc1 \
  curl \
  libpcre3 \
  libc6 \
  libstdc++6 \
  libkrb5-3 \
  openssl \
  debconf \
  openssh-server \
  libleptonica-dev \
  python3-opencv \
  tesseract-ocr \
  libtesseract-dev \
  tesseract-ocr-eng \
  tesseract-ocr-script-latn \
  imagemagick \
  libsm6 \
  libxext6 \
  libgl1-mesa-glx



#to solve the problem with the db REF::
#https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17



#Copy and install everything at ./
COPY requirements.txt .
RUN pip install -r requirements.txt --no-cache-dir

COPY white_list.txt .
COPY namelist.txt .
COPY org_names.txt .
COPY health.txt .
COPY blankIT_db_stuff.py .
COPY blankIT_utils.py .
COPY blankitbe.py .
COPY . /app
WORKDIR /app

#the lines below added Dec23 - as suggested by stack overflow
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base


CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--workers", "1", "--timeout", "360", "--log-level", "debug", "blankitbe:app"]

And the commands i run in the Azure window is:

az login

az acr build --registry blankitbeAppRegistry --resource-group blankitbeApp --image blankitbe-app .

az appservice plan create -g blankitbeApp -n blankitbeAppServicePlan -l westeurope --is-linux --sku P3V2

az webapp create -g blankitbeApp -p blankitbeAppServicePlan -n blankitbe-web-app -i blankitbeAppregistry.azurecr.io/blankitbe-app:latest

This all seem to install ok, but the webapp does not start... :-(

From the log (see below) it appears as if there s a problem with gunicorn or some PATH, but i do not understand?

Help would be much appreciated.

The log files now say:

2023-12-10T17:10:36.862Z ERROR - Container start failed for blankitbe-web-app_0_e71529ab with System.AggregateException, One or more errors occurred. (Docker API responded with status code=BadRequest, response={"message":"failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: \"gunicorn\": executable file not found in $PATH: unknown"}
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,991 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,182 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Thomas Elboth 10 Reputation points
    2023-12-12T20:22:01.8733333+00:00

    I finally figured out the problem:

    In my requirements.txt file two instances of openCV:

    run command: pip list | grep opencv

    opencv-python==4.5.5.62

    opencv-contrib-python

    The solution was simpy to remove the last line above - and then everything worked...


  2. Pinaki Ghatak 5,600 Reputation points Microsoft Employee Volunteer Moderator
    2024-02-02T09:28:48.88+00:00

    Hello @Thomas Elboth

    It seems like there is an issue with the gunicorn executable file not being found in the PATH. You can try adding the following line to your Dockerfile to add the gunicorn executable to the PATH:

    This should add the `/usr/local/bin` directory to the PATH, which is where gunicorn is installed by default. Also, make sure that the CMD command in your Dockerfile is enclosed in quotes, like this: 
    ```CMD ["gunicorn", "-k", "uvicorn.workers.UvicornWorker", "--workers", "1", "--timeout", "360", "--log-level", "debug", "blankitbe:app"]``` 
    
    This will ensure that the command is parsed correctly. 
    After making these changes, rebuild your Docker image and try deploying it again to Azure.
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.