Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS AWS Elastic Beanstalk Deploy issue

I attempted to create an automated release pipeline on Azure DevOps that should build and deploy my applications to my AWS Elastic Beanstalk servers. I am using the recommended AWS Elastic Beanstalk Deploy task to perform this action. It works great for my .NET Core applications, but it has been putting my standard .NET application in a subfolder with the name {ProjectName}_deploy on the server.

I am using the standard VS 2017 build with the package command set, so it is using that zip file created by the standard build process, but I have been unable to figure out why it wants to create a new application in a subfolder instead of placing it in the main Default Web Site folder like it does when I use the Visual Studio deployment tool.

like image 890
Grungondola Avatar asked May 22 '26 20:05

Grungondola


1 Answers

After a lot of research and attempted fixes, I discovered that the fix was to provide a manifest to AWS.

aws-windows-deployment-manifest.json

{
  "manifestVersion": 1,
  "deployments": {
    "msDeploy": [
      {
        "name": "service",
        "parameters": {
          "appBundle": "CSI.Service.zip",
          "iisPath": "/"
        }
      }
    ]
  }
}

This file must be placed within a zip hierarchy as follows:

  • Zip to Upload
    • aws-windows-deployment-manifest.json
    • CSI.Service.zip (application deployment zip file from build)

Edit: Add details about pipelines to build/deploy

For my deployment process, I use a Build Pipeline to package the project up into the zip files (multiple for some projects that use multiple instances of elastic beanstalk). After that, I run a Release Pipeline to deploy the change to Elastic Beanstalk

Build Pipeline

In the build pipeline, I basically build the solution, which packages the Web API into a zip file, copy the zip file and AWS manifest file to a folder together, and then zip them up into the build drop zone. It is also important to note that the name of the manifest file is important, as it must match what Amazon expects it to be. Otherwise, it will be ignored. It is also important to make sure you set the Archive task to not prepend the root folder name to the archive paths.

steps:
- task: VSBuild@1
  displayName: 'Build solution **\*.sln $(BuildConfiguration)'
  inputs:
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
    platform: '$(BuildPlatform)'
    configuration: '$(BuildConfiguration)'
    clean: true

steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\eb-deploy\'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)\CSI.Service'
    Contents: 'aws-windows-deployment-manifest.json'
    TargetFolder: '$(Build.ArtifactStagingDirectory)\eb-deploy\'

steps:
- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)\eb-deploy\'
  inputs:
    SourceFolder: '$(Build.ArtifactStagingDirectory)'
    Contents: CSI.Service.zip
    TargetFolder: '$(Build.ArtifactStagingDirectory)\eb-deploy\'

steps:
- task: ArchiveFiles@2
  displayName: 'Archive $(Build.ArtifactStagingDirectory)\eb-deploy\'
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\eb-deploy\'
    includeRootFolder: false
    archiveFile: '$(Build.ArtifactStagingDirectory)/drop/Service/eb-deploy-service-$(shared.environmentExtension).zip'

Release Pipeline

The release pipeline simply takes the created zip file from the build and pushes it up to the corresponding AWS Elastic Beanstalk application/environment.

steps:
- task: AmazonWebServices.aws-vsts-tools.BeanstalkDeployApplication.BeanstalkDeployApplication@1
  displayName: 'Deploy to Elastic Beanstalk: $(service.environmentName)$(shared.environmentExtension)'
  inputs:
    awsCredentials: 'My AWS'
    regionName: 'us-east-1'
    applicationName: '$(service.applicationName)'
    environmentName: '$(service.environmentName)$(shared.environmentExtension)'
    webDeploymentArchive: '$(System.DefaultWorkingDirectory)\_CSI Build\drop\Service\eb-deploy-service-$(shared.environmentExtension).zip'
like image 88
Grungondola Avatar answered May 25 '26 05:05

Grungondola



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!