嗨,我正在尝试部署通用的通用Web应用程序
我按照以下问题中的步骤操作:Deploying Angular Universal to Azure
一切都进行得很顺利,但是当我尝试访问该网址时,它给了我Http错误500
我检查了根文件夹的内容,然后看到server.js和包含浏览器和服务器文件夹的dist文件夹。
在我遵循的指南中,我说到那里应该有server.js,web.config和dist文件夹。该构建未生成我认为是问题原因的web.config文件。
以下是该版本的yml文件:
#Your build pipeline references an undefined variable named ‘Parameters.ConnectedServiceName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppKind’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy Azure App Service'
inputs:
azureSubscription: '$(Parameters.ConnectedServiceName)'
appType: '$(Parameters.WebAppKind)'
WebAppName: '$(Parameters.WebAppName)'
packageForLinux: 'website/app'
WebConfigParameters: '-Handler iisnode -NodeStartFile server.js -appType node'
enableCustomDeployment: true
ExcludeFilesFromAppDataFlag: false
以下是用于构建的yml文件:
pool:
name: Hosted
steps:
- task: NodeTool@0
displayName: 'Use Node 10.x'
inputs:
versionSpec: 10.x
checkLatest: true
- task: Npm@1
displayName: 'npm install angular cli'
inputs:
command: custom
verbose: false
customCommand: 'install @angular/cli -g'
- task: Npm@1
displayName: 'npm install packages'
inputs:
verbose: false
- script: 'npm run build:ssr'
displayName: 'build the project'
- task: CopyFiles@2
displayName: 'Copy Files to Staging'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/dist'
TargetFolder: '$(Build.ArtifactStagingDirectory)/app/dist'
- task: CopyFiles@2
displayName: 'Copy server.js to the root'
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)/app/dist'
Contents: server.js
TargetFolder: '$(Build.ArtifactStagingDirectory)/app'
- task: DeleteFiles@1
displayName: 'Delete the dist/server.js'
inputs:
SourceFolder: '$(Build.ArtifactStagingDirectory)/app/dist'
Contents: server.js
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: website'
inputs:
ArtifactName: 'website'
我想知道是什么原因导致网站显示Http错误500,以及为什么没有生成web.config文件。
谢谢,和平了!
编辑:我已经检查了发行版上的日志,并且生成了一个web.config文件。我还检查了应用程序服务上的日志,错误是
Application has thrown an uncaught exception and is terminated:Error: Cannot find module 'zone.js/dist/zone-node'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:20:18)at Object.<anonymous> (D:\home\site\wwwroot\server.js:167:18)at _webpack_require_ (D:\home\site\wwwroot\server.js:20:30)at Module.<anonymous> (D:\home\site\wwwroot\server.js:93:80)at _webpack_require_ (D:\home\site\wwwroot\server.js:20:30)at D:\home\site\wwwroot\server.js:84:18at Object.<anonymous> (D:\home\site\wwwroot\server.js:87:10)Application has thrown an uncaught exception and is terminated:Error: Cannot find module 'zone.js/dist/zone-node'at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)at Function.Module._load (internal/modules/cjs/loader.js:507:25)at Module.require (internal/modules/cjs/loader.js:637:17)at require (internal/modules/cjs/helpers.js:20:18)at Object.<anonymous> (D:\home\site\wwwroot\server.js:167:18)at _webpack_require_ (D:\home\site\wwwroot\server.js:20:30)at Module.<anonymous> (D:\home\site\wwwroot\server.js:93:80)at _webpack_require_ (D:\home\site\wwwroot\server.js:20:30)at D:\home\site\wwwroot\server.js:84:18at Object.<anonymous> (D:\home\site\wwwroot\server.js:87:10)