amazon-web-services - 将 ASP.NET Core 部署到 AWS Elastic Beanstalk,必须包含一个带有 '.runtimeconfig.json' 后缀错误的文件

标签 amazon-web-services asp.net-core deployment amazon-elastic-beanstalk

我正在尝试使用 Bitbucket 管道将 ASP.NET Core(dotnet 版本 5.0)部署到 AWS Elastic Beanstalk,但部署步骤导致错误:实例部署:您的源包有一个 .NET Core 应用程序。您必须包含一个带有“.runtimeconfig.json”后缀的文件。部署失败。
弹性 Beanstalk 设置:

  • 平台:Linux 上的 .NET Core
  • 平台分支:在 64 位 Amazon Linux 2 上运行的 .NET Core
  • 平台版本:2.1.0(推荐)

  • (使用#some_text 更改敏感数据)
    Elastic Beanstalk 日志:
    2020-12-04 02:04:16 UTC+0100 ERROR During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
    2020-12-04 02:04:16 UTC+0100 ERROR Failed to deploy application.
    2020-12-04 02:04:16 UTC+0100 ERROR Unsuccessful command execution on instance id(s) '#id'. Aborting the operation.
    2020-12-04 02:04:16 UTC+0100 INFO  Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
    2020-12-04 02:04:16 UTC+0100 ERROR [Instance: #id] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
    2020-12-04 02:04:13 UTC+0100 ERROR Instance deployment: Your source bundle has a single .NET Core application. You must include a file with a '.runtimeconfig.json' suffix. The deployment failed.
    2020-12-04 02:04:13 UTC+0100 INFO  Instance deployment found a runtime-dependent .NET Core application in your source bundle.
    2020-12-04 02:04:13 UTC+0100 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
    2020-12-04 02:04:10 UTC+0100 INFO  Deploying new version to instance(s).
    
    eb-engine.log:
    2020/12/04 01:04:13.566295 [INFO] Executing instruction: StageApplication
    2020/12/04 01:04:13.569996 [INFO] extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/
    2020/12/04 01:04:13.570035 [INFO] Running command /bin/sh -c /usr/bin/unzip -q -o /opt/elasticbeanstalk/deployment/app_source_bundle -d /var/app/staging/
    2020/12/04 01:04:13.688429 [INFO] finished extracting /opt/elasticbeanstalk/deployment/app_source_bundle to /var/app/staging/ successfully
    2020/12/04 01:04:13.689890 [INFO] Executing instruction: RunAppDeployPreBuildHooks
    2020/12/04 01:04:13.689914 [INFO] The dir .platform/hooks/prebuild/ does not exist in the application. Skipping this step...
    2020/12/04 01:04:13.689920 [INFO] Executing instruction: CheckProcfileForDotNetCoreApplication
    2020/12/04 01:04:13.689925 [INFO] checking application and updating executable file permissions...
    2020/12/04 01:04:13.690272 [INFO] found runtime-dependent application...
    2020/12/04 01:04:13.690294 [INFO] checking Procfile...
    2020/12/04 01:04:13.690317 [ERROR] An error occurred during execution of command [app-deploy] - [CheckProcfileForDotNetCoreApplication]. Stop running the command. Error: there is no .runtimeconfig.json file for your single application. Please provide a valid application
    
    比特桶管道:
    (缩短 - 只是相关步骤)
    image: mcr.microsoft.com/dotnet/sdk:5.0
    
    pipelines:
        test:
          - step:
              name: "Create release of Api project"
              script:
                - export API_PROJ=path/to/my/project.csproj
                - export CONFIG=Release
                - dotnet publish -c $CONFIG $API_PROJ -o api
              artifacts:
                - api/**
          - step:
              name: "Zip"
              image: atlassian/default-image:2
              script:
                - zip api.zip api/*
              artifacts:
                - api.zip
            - step:
              name: "Deploy to Elastic Beanstalk"
              script:
                - pipe: atlassian/aws-elasticbeanstalk-deploy:0.6.7
                  variables:
                    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
                    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
                    DB_CONNECTION_STRING: $DB_CONNECTION_STRING
                    AWS_DEFAULT_REGION: "eu-west-2"
                    APPLICATION_NAME: "#the_app"
                    ENVIRONMENT_NAME: $BITBUCKET_BRANCH
                    ZIP_FILE: "api.zip"
                    S3_BUCKET: '#S3_BUCKET'
    
    从日志看来,AWS 找不到后缀为“.runtimeconfig.json”的文件,但它位于 zip 文件中:
    application release build (目录打印屏幕)
    到目前为止,我已经尝试从 Bitbucket 管道和我的笔记本电脑部署应用程序。我什至尝试部署自包含构建,但解决了同样的错误。我的一位同事使用 Visual Studio Elastic Beanstalk 部署工具成功部署了它,但这并不能解决我们的问题,这只是临时修复。我曾尝试添加 Procfile,但没有效果。
    我还没有找到 Elastic Beanstalk 的任何配置吗?任何想法和建议将不胜感激。

    最佳答案

    这是因为 EB 寻找 runtimeconfig.json在根目录。如果您解压缩您的 zip,您将拥有这样的目录结构 -

    randomName.zip > random name created by EB
      api
        -runtimeconfig.json
        -
    
    虽然它应该看起来像
    {randomName.zip} > random name created by EB
      -runtimeconfig.json
    
    因此,将您的构建规范工件更改为 api/**./**应该管用。这是我在 Github 上的工作示例 - https://gist.github.com/vickyrathee/06df1416d8bc5f2543c56e4d3b912e96

    关于amazon-web-services - 将 ASP.NET Core 部署到 AWS Elastic Beanstalk,必须包含一个带有 '.runtimeconfig.json' 后缀错误的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65172466/

    相关文章:

    macos - 创建 EC2 集群 : 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)

    amazon-web-services - 如何解析AWS VPC弹性IP地址的 "The maximum number of addresses has been reached"?

    c# - 在没有 DI 的情况下登录 .NET Core?

    macos - 没有应用程序包的 QT 命令行可执行二进制文件有 Macdeployqt 吗?

    java - 部署应用程序时的Weblogic Guava问题

    Tomcat 在部署新版本时取消部署旧版本

    php - 如何在AWS中低成本运行laravel php应用程序?

    amazon-web-services - X 任务失败后取消 AWS CDK 部署

    javascript - Angular 5/6 : Handle File Download (w/Friendly File Name) from ASP. NET 核心 API HTTP

    c# - 如何在Mvc中编写RedirectToAction的扩展方法来设置TempData?