React and AppSettings in Azure

2019-08-03 18:47发布

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 :

  1. 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.

  2. 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条回答
Juvenile、少年°
2楼-- · 2019-08-03 19:14

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:

enter image description here

查看更多
登录 后发表回答