简体   繁体   English

无法将 React 应用部署到 azure 应用服务

[英]Cannot deploy a react app to azure app services

I'm trying to deploy a basic react app to Azure app services, but I cannot get it to work.我正在尝试将一个基本的 React 应用程序部署到 Azure 应用程序服务,但我无法让它工作。

The app itself is the initial app created following npx create react app my-app command.该应用程序本身是根据npx create react app my-app命令创建的初始应用程序。 I want to get this one working first before trying to deploy my actual react app.在尝试部署我的实际 React 应用程序之前,我想让它先工作。

The Azure App Service is a Linux setup, using node 16. I've added “pm2 serve /home/site/wwwroot --no-daemon” as the startup command. Azure 应用服务是一个 Linux 设置,使用节点 16。我添加了“pm2 serve /home/site/wwwroot --no-daemon”作为启动命令。 I've also added PORT 3000 and WEBSITE_PORT 3000 in app settings.我还在应用程序设置中添加了 PORT 3000 和 WEBSITE_PORT 3000 。

Lastly I've added a web.config file to the react app itself.最后,我向 React 应用本身添加了一个 web.config 文件。

Nothing I do seems to work though as it is not loading at all.我所做的一切似乎都不起作用,因为它根本没有加载。 I just get 'application error' if I try to open the app.如果我尝试打开应用程序,我只会收到“应用程序错误”。

The only two errors i can see in the logs are:我在日志中看到的唯一两个错误是:

“…didn't respond to HTTP pings on port: 3000” and “… did not start within expected time limit” “……没有响应 HTTP 端口上的 ping:3000”和“……没有在预期的时限内启动”

My deployment is set as continuous via git hub, though as this is building without an issue I think the problem must be something in the Azure App Service settings but I'm lost as to what.我的部署通过 git 集线器设置为连续部署,但由于这是在构建时没有问题,我认为问题一定出在 Azure 应用服务设置中,但我不知道是什么。

Does anyone have any ideas to fix this?有没有人有解决这个问题的想法?

It could be that there is no access to port 3000 in the app service.可能是应用服务没有访问3000端口。

It depends on how you have set it up what needs to be fixed.这取决于您如何设置需要修复的内容。 It could be the.network settings on the app service.它可能是应用程序服务上的网络设置。 If your app service is on a .NET then it could be the settings on the .NET that need to be updated.如果您的应用程序服务位于 .NET 上,则可能需要更新 .NET 上的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用哪些 azure 服务(AKS 或 App 服务)在 azure 上部署多个 docker 容器(启用组合) - Which azure services to use ( AKS or App service) to deploy multiple docker containers (compose enabled) on azure 部署Azure function到微软Azure中的应用服务 - Deploy Azure function to app service in Microsoft Azure 仅将构建的 React 应用程序部署到应用程序引擎 - Deploy only build react app to app engine 使用 Azure 管道/发布将 Vue 应用部署到 Azure 应用服务 - Deploying a Vue app to Azure App Services with Azure Pipelines/releases 在子目录下部署应用程序 - Azure - Deploy App Under Sub-directory - Azure 如何将python app部署到Azure Function - How to deploy python app to Azure Function 如何从github部署到Azure应用服务 - How to Deploy from github to Azure App Service Azure Devops如何部署static angular app到azure blob存储 - Azure Devops how to deploy static angular app to azure blob storage 如何使用 VSCode 修复 Azure web 应用程序部署错误? - How fix Azure web app deploy error with VSCode? 将代码从 Azure repo 部署到 Function app slot - Deploy code from Azure repo to Function app slot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM