[英]How to deploy React to Azure Web App using the Azure App Service plugin in Visual Studio Code?
I tried following the many existing questions and blogs online but I couldn't get it to work, I have created a simple React app with this setup:我尝试在网上关注许多现有的问题和博客,但我无法让它工作,我用这个设置创建了一个简单的 React 应用程序:
It run fine locally.它在本地运行良好。 I also ran "npm run build".
我还运行了“npm run build”。 I also added a web.config to my public folder, which got copied to my build folder with the following content:
我还在我的公共文件夹中添加了一个 web.config,它被复制到我的构建文件夹中,内容如下:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Detailed"></httpErrors>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
My public folder look like this:我的公用文件夹如下所示:
I create my Azure Web App online fine and I was able to deploy to it but I browse to it I get this error:我在线创建了我的 Azure Web 应用程序,并且能够部署到它,但是我浏览到它时出现此错误:
The page cannot be displayed because an internal server error has occurred.
What error do I have?我有什么错误?
The page cannot be displayed because an internal server error has occurred.
由于发生内部服务器错误,无法显示该页面。
This error may occur if application is not deployed properly or dependencies are not loaded.如果未正确部署应用程序或未加载依赖项,则可能会发生此错误。
Steps to deploy React to Azure Web App :将 React 部署到 Azure Web App 的步骤:
Open your Project in VS Code在 VS Code 中打开你的项目
Go to Extensions.转到扩展。 Search for Azure App Service and click on Install.
搜索 Azure 应用服务并单击安装。
Go to Azure App Service.转到 Azure 应用服务。 Sign in to your Azure Account.
登录到你的 Azure 帐户。
Click on Deploy to Web App.单击部署到 Web 应用程序。
Select your Subscription.选择您的订阅。 Select your App Service.
选择您的应用服务。
Now you should be able to deploy your react app to Azure App Service现在您应该能够将您的 React 应用程序部署到 Azure 应用服务
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.