简体   繁体   中英

Azure Linux container on Web app environmental variables

I have a configuration that runs a Node docker container on azure as a Webapp. Everywhere i read it clearly says that App Settings ( environmental variables ) set to the Web app will be injected at runtime to the container, but it's clearly not the case for me.

"When your app runs, the App Service app settings are injected into the process as environment variables automatically"

https://docs.microsoft.com/en-us/azure/app-service/configure-custom-container?pivots=container-linux#configure-environment-variables

Dockerfile:

FROM node

# Open SSH for Azure
RUN apt-get update && apt-get install -y ssh
RUN echo "root:Docker!" | chpasswd
RUN mkdir /run/sshd
COPY sshd_config /etc/ssh/

# Copy resources
WORKDIR /app
COPY package*.json ./

# Run install
RUN npm install
COPY . .

# Copy startup script and make it executable
COPY startup.sh /app
RUN ["chmod", "+x", "/app/startup.sh"]

startup.sh:

#!/bin/sh

echo "Start sshd"
/usr/sbin/sshd

echo "Start node"
node server.js

And still (as an example):

secret: process.env.ADDSEARCH_SECRET

And still process.env.ADDSEARCH_SECRET clearly returns null. As well as all the reset of the variables

Azure 环境映像

What am I missing?

Using it with build_args during the build step of the docker image works, but I really don't want to do it that way for several reasons.

您需要在环境变量前加上APPSETTING_前缀,例如APPSETTING_ADDSEARCH_SECRET

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM