Nextjs App reading configuration from Azure App Service

veera ravula 21 Reputation points
2022-07-20T06:44:54.757+00:00

We have a nextjs project which is build by docker and deploy into Azure App Service (container). We also setup configuration values within App Service and try to access it, however its not working as expected.

Few things we tried

Restarting the App Service after adding new configuration

removing .env file while building the docker image

including .env file while building the docker image

222573-image.png
Here's how we read try to read the environment variables within the App Service

onst env = process.env.NEXT_PUBLIC_ENV;  
  const A = process.env.NEXT_PUBLIC_AS_VALUE;  

Wondering if this can actually be done? Just thinking something out loud below,

Since we're deploying the docker image within App Service's Container (Linux).. does that mean, the container can't pull the value from this environment variable?

Docker image already perform the npm run build, would that means the image is in static formed (build time). It will never ready from App Service configuration (runtime).

Developer technologies | .NET | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-08-14T15:52:42.3233333+00:00

    you want to set the environment variable setting in the container configuration:

    https://learn.microsoft.com/en-us/azure/app-service/configure-custom-container?tabs=debian&pivots=container-linux

    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.