问题
I followed the contents of three different tutorials in deploying a slightly-modified boilerplate React app to Azure App Services. The primary issue I'm having is that while all deployment pipelines and releases have been successful on Azure DevOps, navigating to the page results in the default landing page for non-deployed app services;
Hey, Node developers! Your app service is up and running. Time to take the next step and deploy your code.
I'll briefly describe the steps I took to get to this point:
- I used
create-react-app
to generate a basic template, ran all the prerequisite commands, fiddled with the app.js file and its CSS companion, and left index.* untouched. - I pushed all of it with an untouched gitignore to a Github repository.
- I created an App Service, running Linux and Node 12 LTS, on the Free plan.
- I created a DevOps project, and within it created a Pipeline and a Release Pipeline.
- In the Pipeline: I retrieved my repository source via linked accounts in the Get Sources step. In Agent job 1, I added a
npm install
element, anpm run build
element, and a Publish Artifact element. I set the path tobuild
, and artifact name toartifact
, publishing to Azure Pipelines. - In the Release Pipeline: I added an artifact that grabs its source from the previous pipeline, and gives a source alias of
_artifact
. CD trigger is enabled. I added a stage that has a Deploy Azure App Service element, using$(System.DefaultWorkingDirectory)/_artifact/artifact
as the package/folder.
When I push a commit or manually trigger the first pipeline, everything succeeds with no obvious errors. The Release pipeline is triggered and also completes without error. Checking the logs, the artifact
is stored and accessed accurately. I can see the correct build files being accessed.
In the Azure portal, I can see that deployment has succeeded with the correct timestamp, commit name, and pipelines. However, when I access the actual site, I am shown the generic page.
Am I missing a crucial step somewhere? I've tried navigating to /index.html, /src/index.html, and a bunch of other combinations of known files, but to no avail; Cannot GET /index.html
.
Any insight would be appreciated.
For reference, I used these three walkthroughs:
- https://medium.com/microsoftazure/deploying-create-react-app-as-a-static-site-on-azure-dd1330b215a5
- https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321
- https://www.pluralsight.com/guides/deploy-a-react-app-to-azure
回答1:
This question is very simple, you can refer to the following post.
1. Deploy create-react-app with azure pipelines
2. Unable to deploy React JS application on Azure App service
3. Process for React App deployment to Azure Web?
Suggestion:
It is recommended to choose linux when creating a webapp.
Configuration
->StartupCommand:
pm2 serve /home/site/wwwroot --no-daemon --spa
来源:https://stackoverflow.com/questions/64708381/successful-deployment-still-leads-to-default-page