在 Azure 中部署 React 应用程序,获得 "didn't respond to HTTP pings on port: 8080"

Deploy React app in Azure, getting "didn't respond to HTTP pings on port: 8080"

我正在使用本教程 https://medium.com/geekculture/easiest-way-to-host-your-react-app-azure-vs-code-8046f9f7fb0b 将我新创建的 React App 部署到 Azure App 服务。但是我一直收到以下错误。知道为什么吗?

我尝试了各种来自互联网的故障排除方法,例如

WEBSITES_PORTPORT 设置为 80

但到目前为止运气不好。

2021-10-05T16:31:37.859Z INFO  - Initiating warmup request to container managementlnxdev_0_9e7876cc for site managementlnxdev
2021-10-05T16:31:53.746Z INFO  - Waiting for response to warmup request for container managementlnxdev_0_9e7876cc. Elapsed time = 15.8869901 sec
2021-10-05T16:32:08.969Z ERROR - Container managementlnxdev_0_9e7876cc for site managementsitedev has exited, failing site start
2021-10-05T16:32:08.972Z ERROR - Container managementlnxdev_0_9e7876cc didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2021-10-05T16:32:08.989Z INFO  - Stopping site managementlnxdev because it failed during startup.

我在为容器部署 ReactJs 应用程序到 Azure Web 应用程序时遇到了这个问题

当我将应用程序部署到 Azure 时,我会收到以下错误:

2021-06-10T10:29:05.571Z INFO  - Initiating warmup request to container mediumblogreact_5app for site devopsapptest
2021-06-10T10:29:07.733Z ERROR - Container mediumblogreact_5app for site devopsapptest has exited, failing site start
2021-06-10T10:29:07.737Z ERROR - Container mediumblogreact_5app didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.

默认情况下,应用服务假定您的自定义容器正在侦听端口 80,但是,请将端口更改为 3000

以下 CLI/PowerShell 命令将有助于更改端口值:

在 Azure CLI 中:

az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITES_PORT=8000

在 Azure PowerShell 中:

Set-AzWebApp -ResourceGroupName <group-name> -Name <app-name> -AppSettings @{"WEBSITES_PORT"="8000"}

注意:应用服务目前只允许您的容器为 HTTP 请求公开一个端口。

您可能还希望将 EXPOSE your-port 命令添加到项目的 Dockerfile

资源Configure a custom container for Azure App Service