Deploying a Web Deploy Package to AWS ElasticBeanstalk

AWS provide an extension to Visual Studio to make interacting with your AWS services easy, including deploying to a Beanstalk environment, which is the recommended way of deploying to a Beanstalk.

This works great, and if you are able to, you should obviously use the recommended approach, but there may be times you don’t have the extension available, or already have a build system setup to use Web Deploy packages. As far as I can tell the Beanstalk just uses MsDeploy packages under the hood, making it easy to deploy these without the extension!

1. Create a Package

If you don’t already have a Web Deploy package, create one. This is simple in Visual Studio, open your Web Application, right click on the Web Application project and select Publish.

This will open the Publish Web dialog:

Deploy1

Select Custom, and give your profile a name (for example the beanstalk environment name). On the Connection screen, update the Publish method to Web Deploy Package.

Deploy2Enter Default Web Site for the Site name, and choose a location on your machine to create the package.

Check the Settings are correct on the next screen, confirm your publish location on the Preview screen, and then click Publish.

Navigate to the folder where the package was created, you should see 5 files, the only one of interest for this case is the ZIP file.

 

2. Deploying the package

Browse to your environment in the AWS Management Console

Deploy3Select Upload and Deploy.

 

Deploy4Choose the ZIP file created earlier, and give this version a label (these should be unique amongst labels used for this application).

Clicking Deploy will start the deployment of the code to this environment, you will be able to monitor the logs in the Console to the status of your deployment.

If everything goes to plan you should see a message in the logs saying “New application version was deployed to running EC2 instances.”.

Next Steps

Just as you can automate these steps using the AWS Visual Studio Toolkit and the Deployment Tool command line program, these steps can be automated

The package can be created using MSBuild and the Package target.

The deployment to AWS can be automated using either the CLI tools, or Powershell tools and the following methods

Advertisements