I am trying to deploy ASP.NET Core (dotnet version 5.0) to AWS Elastic Beanstalk with Bitbucket pipelines, but the deploy step results in 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.
Elastic Beanstalk settings:
(changing sensitive data with #some_text)
Elastic Beanstalk logs:
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
Bitbucket pipeline: (Shortened - just relevant steps)
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'
From the logs it looks like AWS can't find file with suffix '.runtimeconfig.json', but it is in the zip file: application release build (directory print screen)
So far I have tried deploying the application from Bitbucket pipelines and my laptop. I have even tried deploying self contained build, but that resolved in the same error. One of my colleagues succeeded by deploying it with Visual Studio Elastic Beanstalk deploy tool, but that does not solves our problem, it is just temporary fix. I have tried adding Procfile, but that had no effect.
Is there any config for the Elastic Beanstalk I haven't found yet? Any ideas and suggestions would be greatly appreciated.
This is because of EB look for runtimeconfig.json
on root directory. If you extract your zip, You will have the directory structure like this -
randomName.zip > random name created by EB
api
-runtimeconfig.json
-
While it should look like
{randomName.zip} > random name created by EB
-runtimeconfig.json
So changing your buildspec artifacts to api/**
to ./**
should work. Here is my working example on Github - https://gist.github.com/vickyrathee/06df1416d8bc5f2543c56e4d3b912e96