Azure container app service environment variables not inside container in runtime

HARSHA VARDHAN V 5 Reputation points
2024-04-07T14:10:25.8733333+00:00

I deployed a azure app service in container mode the environment variables are not being passed to the container in runtime.

when I use print env I don't see them

0437a64035034116b857b570415484fa:~# printenv
MAIL=/var/mail/root
USER=root
SSH_CLIENT=169.254.130.5 58518 2222
SHLVL=1
HOME=/root
SSH_TTY=/dev/pts/0
PAGER=less
LOGNAME=root
TERM=xterm-color
LC_COLLATE=C
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=C.UTF-8
SHELL=/bin/ash
PWD=/root
SSH_CONNECTION=169.254.130.5 58518 169.254.130.4 2222
CHARSET=UTF-8

User's image

I tried ticking and removing the environment deployment slot settings

Here is my Dockerfile


FROM python:3.11-alpine3.19 as build

COPY ./requirements.txt ./

RUN pip3 install --no-cache-dir -r ./requirements.txt

FROM python:3.11-alpine3.19 as final

COPY sshd_config /etc/ssh/

RUN apk update \
    && apk upgrade \
    && apk add openssh \
    && echo "root:Docker!" | chpasswd \
    && cd /etc/ssh/ \
    && ssh-keygen -A

WORKDIR /app/


COPY ./ ./
COPY --from=build /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/


EXPOSE 80/tcp 2222

ENTRYPOINT ["./start.sh"]

I want the environment variables in docker container.

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

2 answers

Sort by: Most helpful
  1. HARSHA VARDHAN V 5 Reputation points
    2024-04-07T16:00:22.82+00:00

    User's image

    I got answer on Reddit faster that's right
    I add the below line in start.sh and it worked thanks to tehho1337

    printenv > .env 
    
    1 person found this answer helpful.

  2. ajkuma 26,141 Reputation points Microsoft Employee
    2024-04-10T09:50:32.5233333+00:00

    @HARSHA VARDHAN V , Glad to see that your issue is resolved and thanks for confirming the solution that worked. Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer. They can only accept answers by others, I' have summarized and posted the solution ( shared by you), request you to Accept the answer, it will benefit the community find the answers quickly.

    Scenario:

    Environment Variables Not Passed to Azure Container App Service in Runtime

    Issue:

    Upon deploying an Azure App Service in container mode, environment variables are not being passed to the container during runtime, as evidenced by the absence of environment variables when checking with 'printenv' command inside the container.

    Resolution:
    @HARSHA VARDHAN V confirmed the solution, answered shared by tehho1337 on reddit forum thread.

    To resolve the issue, the following line was added to the 'start.sh' script:

    printenv > .env
    
    
    

    --Please click Accept Answer- it will benefit the community to find the answers quickly.

    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.