How to run app and enable SSH access on azure web app

Huhn, Alexander 95 Reputation points
2023-02-27T13:10:02.84+00:00

I have an Azure web app that is run from a docker container.

I want to debug and access the CLI while the app is running so I can debug. I followed inatructions here: https://azureossd.github.io/2022/04/27/2022-Enabling-SSH-on-Linux-Web-App-for-Containers/index.html to add an SSH entry point in my docker file, that now reads:

FROM rocker/verse
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends build-essential libpq-dev python3.9 python3-pip python3-setuptools python3-dev
RUN pip3 install --upgrade pip
RUN apt -y install libpng-dev

WORKDIR /app
RUN apt-get install --yes xvfb libgconf-2-4

# install chrome, chromote, and vivaldi
RUN CHROMEDRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` &&     mkdir -p /opt/chromedriver-$CHROMEDRIVER_VERSION &&     curl -sS -o /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip &&     unzip -qq /tmp/chromedriver_linux64.zip -d /opt/chromedriver-$CHROMEDRIVER_VERSION &&     rm /tmp/chromedriver_linux64.zip &&     chmod +x /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver &&     ln -fs /opt/chromedriver-$CHROMEDRIVER_VERSION/chromedriver /usr/local/bin/chromedriver
RUN apt-get update && apt-get install -y gnupg2
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -     && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get -y install google-chrome-stable
RUN wget https://downloads.vivaldi.com/stable/vivaldi-stable_5.5.2805.35-1_amd64.deb
RUN apt-get update && apt-get install -y ./vivaldi-stable_5.5.2805.35-1_amd64.deb && rm -rf /var/lib/apt/lists/*

# Install odbc
RUN sudo su
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN sudo apt-get update && apt install -y apt-utils
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN sudo apt-get remove -y libodbc2 libodbcinst2 odbcinst unixodbc-common
RUN sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17

# Add necessary files
COPY . /app

COPY sshd_config /etc/ssh/

# Start and enable SSH
RUN apt-get update \
    && apt-get install -y --no-install-recommends dialog \
    && apt-get install -y --no-install-recommends openssh-server \
    && echo "root:Docker!" | chpasswd \
    && chmod u+x /app/entrypoint.sh

EXPOSE 8000 2222

RUN pip3 install -r requirements.txt
RUN Rscript requirements.R
#RUN Rscript save_plotly.R
#RUN Rscript save_ggplot.R

RUN Rscript save_png.R
COPY corbell.ttf /usr/share/fonts/
RUN Rscript save_flextable.R
#RUN Rscript generate_summary_images_only.R
#RUN Rscript port_level_analysis.R
#	RUN Rscript generate_app_ppt_images_only.R
EXPOSE 8501
RUN chmod -R 777 /app
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
ENTRYPOINT ["streamlit", "run", "app.py"]

I run my app successfully, but when I access SSH from azure portal, I get the following

User's image

This has been on for 40min, and I have interacted and found bugs I would like to solve from my running web app

Are there any other suggestions to get this functional? TIA

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,837 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. brtrach-MSFT 15,176 Reputation points Microsoft Employee
    2023-03-02T08:34:00.1133333+00:00

    It seems like you are trying to access the SSH of your Azure web app that is running in a Docker container. The error message "waiting for new container(s) to start" suggests that the container is not yet running or is not accessible.

    Here are a few suggestions that might help you resolve the issue:

    1. Check the status of the container instance in the Azure portal to see if it is running.
    2. Verify that the port 2222 is open and accessible (In APPLICATION SETTINGS you need to set the key / value pair WEBSITES_PORT.)
    3. Make sure that the SSH service is running on the container.
    4. Check the logs of the container instance for any error messages.

    Can you please let us know the results of the above suggestions? Especially if you notice errors in the logs.


  2. brtrach-MSFT 15,176 Reputation points Microsoft Employee
    2023-03-24T06:06:47.2033333+00:00

    To Enable SSH for an Ubuntu/Debian based Linux Container, we need to create 3 files.

    Dockerfile

    sshd_config

    An entrypoint script

    FileCode.txt

    I would request you to please create the above three files and push it to the images (Deployment).

    After deployment, you would see below folder structure under the application files.

    User's image

    0 comments No comments