asp.net Azure DevOps将.NET 6应用部署到AWS Elastic Beanstalk时引发“命令挂钩失败”错误

omvjsjqw  于 2022-12-05  发布在  .NET
关注(0)|答案(1)|浏览(87)

我以前的Azure DevOps管道退出了与AWS弹性Beanstalk的dotnet 6部署的合作。
我找到了此指南--〉https://docs.aws.amazon.com/vsts/latest/userguide/tutorial-eb.html
按照这些使用msbuild而不是dotnet build的步骤进行操作似乎可以工作,但是部署到弹性beanstalk失败,出现了一个我以前没有见过的新错误:Error occurred during build: Command hooks failed
部署任务的YAML如下所示...

- task: NuGetToolInstaller@1
    displayName: Use NuGet 5.x
    inputs:
      versionSpec: 5.x
      checkLatest: true
  - task: NuGetCommand@2
    displayName: NuGet restore
    inputs:
      noCache: true
  - task: VSBuild@1
    displayName: Build Project
    inputs:
      solution: AppName/AppName/AppName.csproj
      msbuildArgs: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp_$(build.BuildId).zip" /p:DeployIisAppPath="Default Web Site"
      platform: x64
      configuration: release
      clean: true
      msbuildArchitecture: x64
  - task: BeanstalkDeployApplication@1
    displayName: 'Deploy to Elastic Beanstalk: AppName'
    inputs:
      awsCredentials: 63ff2436-14ff-4391-836c-c14f27af9473
      regionName: us-east-1
      applicationName: AppName
      environmentName: appname-dev
      webDeploymentArchive: $(build.artifactstagingdirectory)\WebApp_$(build.BuildId).zip
      dotnetPublishPath: $(build.artifactstagingdirectory)\WebApp_$(build.BuildId).zip
      versionLabel: 'Azure DevOps Build Id: $(build.buildid)'
      description: $(Build.SourceVersionMessage)

我正在使用以下...

Azure DevOps
Elastic Beanstalk: IIS 10.0 running on 64bit Windows Server Core 2019/2.10.6
Region: us-east-1
Code: dotnet 6

这是cfn-init.log的相关部分

2022-12-02 10:39:38,488 [INFO] -----------------------Starting build-----------------------
2022-12-02 10:39:38,520 [INFO] Running configSets: Infra-WriteRuntimeConfig, Infra-EmbeddedPreBuild, Hook-PreAppDeploy, Infra-EmbeddedPostBuild, Hook-EnactAppDeploy, Hook-PostAppDeploy
2022-12-02 10:39:38,520 [INFO] Running configSet Infra-WriteRuntimeConfig
2022-12-02 10:39:38,535 [INFO] Running config Infra-WriteRuntimeConfig
2022-12-02 10:39:38,582 [INFO] Command 01mkdir succeeded
2022-12-02 10:39:38,832 [DEBUG] CloudFormation client initialized with endpoint https://cloudformation.us-east-1.amazonaws.com
2022-12-02 10:39:38,832 [DEBUG] Describing resource AWSEBAutoScalingGroup in stack arn:aws:cloudformation:us-east-1:265786937427:stack/awseb-e-eqhz5scteh-stack/590b1f30-71af-11ed-bc49-0af991946407
2022-12-02 10:39:38,988 [INFO] Command 02writeappsource succeeded
2022-12-02 10:39:38,988 [INFO] Waiting 5 seconds for reboot
2022-12-02 10:39:44,473 [DEBUG] CloudFormation client initialized with endpoint https://cloudformation.us-east-1.amazonaws.com
2022-12-02 10:39:44,473 [DEBUG] Describing resource AWSEBAutoScalingGroup in stack arn:aws:cloudformation:us-east-1:265786937427:stack/awseb-e-eqhz5scteh-stack/590b1f30-71af-11ed-bc49-0af991946407
2022-12-02 10:39:44,598 [INFO] Command 03writeconfig succeeded
2022-12-02 10:39:44,613 [INFO] Running configSet Infra-EmbeddedPreBuild
2022-12-02 10:39:44,613 [INFO] Running configSet Hook-PreAppDeploy
2022-12-02 10:39:44,629 [INFO] Running config Hook-PreAppDeploy
2022-12-02 10:40:45,402 [INFO] Command hooks succeeded
2022-12-02 10:40:45,449 [INFO] Running configSet Infra-EmbeddedPostBuild
2022-12-02 10:40:45,464 [INFO] Running configSet Hook-EnactAppDeploy
2022-12-02 10:40:45,480 [INFO] Running config Hook-EnactAppDeploy
2022-12-02 10:41:07,089 [ERROR] Command hooks (HooksExecutor.exe appdeploy\enact) failed
2022-12-02 10:41:07,089 [ERROR] Error encountered during build of Hook-EnactAppDeploy: Command hooks failed
Traceback (most recent call last):
  File "cfnbootstrap\construction.pyc", line 578, in run_config
  File "cfnbootstrap\construction.pyc", line 146, in run_commands
  File "cfnbootstrap\command_tool.pyc", line 127, in apply
cfnbootstrap.construction_errors.ToolError: Command hooks failed
2022-12-02 10:41:07,089 [ERROR] -----------------------BUILD FAILED!------------------------
2022-12-02 10:41:07,089 [ERROR] Unhandled exception during build: Command hooks failed
Traceback (most recent call last):
  File "cfn-init", line 176, in <module>
  File "cfnbootstrap\construction.pyc", line 137, in build
  File "cfnbootstrap\construction.pyc", line 564, in build
  File "cfnbootstrap\construction.pyc", line 578, in run_config
  File "cfnbootstrap\construction.pyc", line 146, in run_commands
  File "cfnbootstrap\command_tool.pyc", line 127, in apply
cfnbootstrap.construction_errors.ToolError: Command hooks failed
2022-12-02 11:05:58,862 [DEBUG] CloudFormation client initialized with endpoint https://cloudformation.us-east-1.amazonaws.com
2022-12-02 11:05:58,862 [DEBUG] Describing resource AWSEBAutoScalingGroup in stack arn:aws:cloudformation:us-east-1:265786937427:stack/awseb-e-eqhz5scteh-stack/590b1f30-71af-11ed-bc49-0af991946407

直接从Visual Studio部署,无论是通过Publish to AWS还是通过Publish to AWS Elastic Beanstalk (Legacy),都可以很好地工作,即使它们是完全相同的代码并进入完全相同的环境。
这似乎不是代码或环境问题。
此外,构建和发布过程也顺利完成,只有在部署到AWS Elastic Beanstalk后才会失败。
任何帮助都是非常感谢的...

wz8daaqr

wz8daaqr1#

在指涉和调查期间,我有两个变通方法可供您使用。
1.切换到ElasticBeanstalk设置中的不可变部署。
2.此问题也可能是由于大量使用示例造成的,您可以尝试升级EC2示例大小。

相关问题