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:
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.
Enter 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
Select Upload and Deploy.
Choose 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.”.
The package can be created using MSBuild and the Package target.
- Upload to S3 Bucket (CLI | Powershell)
- Create Beanstalk Application Version (CLI | Powershell)
- Update Beanstalk Environment (CLI | Powershell)