且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用不带Node Server的AppSettings创建React App

更新时间:2023-01-23 13:59:06

你好mwarnsley,

Hi mwarnsley,

是的,我相信这是可能的。 你现在好吗?上传你的应用程序?

Yes, I believe this is possible. How are you currently uploading your app?

在门户网站中,应用程序设置部分包含您的网络应用程序在启动时加载的名称/值对。对于
.NET apps ,这些设置会在运行时注入.NET配置App Settings,覆盖现有设置。

In the portal, the App settings Section contains name/value pairs that your web app will load on start up. For .NET apps, these settings are injected into your .NET configuration App Settings at runtime, overriding existing settings.

PHP,Python,Java和Node apps 可以在运行时将这些设置作为环境变量进行访问。对于每个应用程序设置,都会创建两个环境变量;一个具有app设置条目指定的名称,另一个具有前缀
的APPSETTING_。两者都包含相同的值。  NODE_ENV = production设置环境变量,告知Node.js在生产环境中运行。 node server.js在您的存储库根目录中使用server.js启动Node.js服务器。这就是您在Azure中加载Node.js
应用程序的方式。

PHP, Python, Java and Node apps can access these settings as environment variables at runtime. For each app setting, two environment variables are created; one with the name specified by the app setting entry, and another with a prefix of APPSETTING_. Both contain the same value. NODE_ENV=production sets the environment variable that tells Node.js to run in the production environment. node server.js starts the Node.js server with server.js in your repository root. This is how your Node.js application is loaded in Azure.

您可以使用 process.env.ENV_VARIABLE
读取
Node中的环境变量。您可以尝试强制
environmental变量
到脚本中的package.json代码中。有关详细信息,请参阅
在Node.js中读取环境变量
。此外,此文档将向您展示如何在Azure App Service上部署您的节点应用程序。

You could use process.env.ENV_VARIABLE to read environment variables in Node. You can try to force environmental variables into the code from package.json in the scripts. See Read environment variables in Node.js for details. Also, this documentation shows you how to deploy your node app on Azure App Service.

希望有所帮助。如果您有其他问题,请告诉我们。

Hope that helps. Please let us know if you have additional question.