React and AppSettings in Azure

一曲冷凌霜 提交于 2020-01-05 04:19:06

问题


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:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!