To access REACT_APP_* environment variables within the React app deployed on Azure app services

Rajashri Udhoji 0 Reputation points


I tried below ways to read REACT_APP_* variables on the React App deployed on App service:

  1. Add all the REACT_APP_* to App service -> Configuration -> Application settings : Read the variables within React app as process.env.REACT_APP_*
  2. Add them to the Azure devOps release pipeline : Read the variables within React app as process.env.REACT_APP_
    User's image
  3. Pass the variables to Yml script via Variable group , secure files.

Deployment to App service using Azure devops is successful however, the environment variables are not getting passed.

Kindly help me with the correct way to solve this environment variable issue.


Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
5,604 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 17,436 Reputation points Microsoft Employee

    Based on my understanding of your scenario description, you have tried 3 approaches to set environment variables in Azure App Service for react app.

    If you are building for production to generate the /build locally and then deploying with the /build folder to Azure, verify that the environment variables are accessible in your local environment so they are injected during build time.

    Kindly checkout this doc section for the steps : Environment variables are missing after deployment. - Also, checkout note - For more information on how React uses and expects environment variables.

    Just to highlight, also add REACT_APP_MY_ENV_VAR for MY_ENV_VAR. The variable can be accessed using process.env.REACT_APP_MY_ENV_VAR.

    Find this sample at for alternative approach.

    Also, checkout this discussion thread:

    If you're still having issues with passing environment variables to your app, please provide more details about the error message or exact behavior you're experiencing.

    0 comments No comments