问题
My goal is to retrieve some environnement keys from Azure Application settings like api_url.
My build factory is the following :
- webpack for the tsx to minified js
- build and release with VSTS
- deploy on Azure Web App
There is no node.js running on Azure Web App, it is just a static server that serve index.html, bundle.js and assets.
I have tried this different method :
Below this example, if I load system vars, I will be able to retrieve this key/value. I have tried with
dotenv-webpack
and systemvars to true but nothing is loaded, obviously I don't have a nodejs server.I've found an url https://mywebsite.scm.azurewebsites.net/api/settings that give me a JSON with all settings, including custom appsettings. So my question is how I can get this, whether in live runtime (this url is protected by account credentials, can I access from web app), or maybe in built process, but in this case, how to access from VSTS ?
Thanks for your help.
回答1:
To get a JSON with all settings you could send a GET request from your reactjs App to this URL:
https://$AZURE_LOGIN:$AZURE_PASS@$AZURE_APPNAME.scm.azurewebsites.net/api/settings
The username and password can be found from Deployment Credentials in the portal of your App Service:
来源:https://stackoverflow.com/questions/48644067/react-and-appsettings-in-azure