Overview

This blog post assumes you’re familiar with the ElasticBeanstalk deployment process, the management UI included in the AWS console, and Azure DevOps build and release pipelines. I’ve documented this here since it was quite time consuming to resolve this issue and neither StackOverflow nor AWS Support had a solution for this issue.

While deploying a .NET Core based application from an Azure DevOps pipeline to an ElasticBeanstalk environment, I kept receiving an error during the deployment step in the engine logs indicating that:

1
2
3
4
5
6
[ERROR] An error occurred during execution of command [app-deploy] - 

[CheckProcfileForDotNetCoreApplication]. Stop running the command. 

Error: error stat /var/app/staging/app/OrganisationName.MicroService: 
no such file or directory with file /var/app/staging/app/OrganisationName.MicroService 

Which was confusing considering I’d modified the solution as documented as part of the AWS ElasticBeanstalk requirements. Additionally, the deployment was using the “Deploy to Elastic Beanstalk” task provided as part of the AWS ElasticBeanstalk deployment plugin.

After troubleshooting further using both the ebcli and the AWS console to retrieve logs, I determined that the issue came from the way the task modified the zip file. The “ebcli ssh” command is a lifesaver as it allows one to view the instance and the deployed application.

To resolve this issue, I came up with a different pipeline deployment method. The pipeline includes three steps,

Archive creation as needed for deployment

A task of type “Archive files” used to create the archive file used for deployment. Deployment to ElasticBeanstalk requires that the application files are in the root directory, published as a self-contained application.

1
2
3
4
5
6
7
steps:
- task: ArchiveFiles@2
  displayName: 'Archive $(System.DefaultWorkingDirectory)/_Build API/drop'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)/_Build API/drop'
    includeRootFolder: false
    verbose: true

Upload to S3 bucket for deployment

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
steps:
- task: AmazonWebServices.aws-vsts-tools.S3Upload.S3Upload@1
  displayName: 'S3 Upload: elasticbeanstalk-ca-central-1-id'
  inputs:
    awsCredentials: 'AWS_EBS_DEPLOY'
    regionName: 'ca-central-1'
    bucketName: 'elasticbeanstalk-ca-central-1-id'
    sourceFolder: '$(Build.ArtifactStagingDirectory)'
    globExpressions: '*.zip'
    targetFolder: 'yourapp-name/yourapp-name-env'

Deployment from the S3 Bucket

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
steps:
- task: AmazonWebServices.aws-vsts-tools.BeanstalkDeployApplication.BeanstalkDeployApplication@1
  displayName: 'Deploy to Elastic Beanstalk: yourapp-name'
  inputs:
    awsCredentials: 'AWS_EBS_DEPLOY'
    regionName: 'ca-central-1'
    applicationName: 'yourapp-name'
    environmentName: 'yourapp-name-env'
    applicationType: s3
    deploymentBundleBucket: 'elasticbeanstalk-ca-central-1-id'
    deploymentBundleKey: 'yourapp-name/yourapp-name-env/$(Build.BuildId).zip'