Problem: How do I create an Elastic Beanstalk application package file for an IIS or .NET application and deploy it using AWSDeploy?
In order to complete the following instructions, you must have the following installed:
- Any supported version of Microsoft Visual Studio.
- AWS Toolkit for Visual Studio, installed with default settings.
Begin by creating a folder structure to store application code, required configuration files, and packages in the same directory as your application resources, similar to the following:
Note: The following procedures refer to these example folders; replace the example folder names with your own folder names.
Last, set up a profile for your AWS account in Visual Studio by following the instructions at Specifying Credentials.
Create an application package that can be used with Elastic Beanstalk via the CLI tools
There are two different processes depending on whether the application bundle is a website project or a .NET project. The following steps show both possible options to create an Application Package.
The required configuration file and commands can be extracted from the interactive process when publishing using AWS Toolkit for Visual Studio.
First, publish your Elastic Beanstalk application using the Visual Studio Publish to AWS wizard by following the instructions at Create an Elastic Beanstalk Environment.
Note: Before publishing, ensure that the Output window is open.
The Output window provides an msdeploy.exe command. The following is an example of this command:
... invoking 'C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe -verb:sync -source:manifest="C:\Users\Administrator\AppData\Local\Temp\2\tmpB5DF.tmp" -dest:package="C:\Users\Administrator\AppData\Local\Temp\2\AWSDeploymentArchive_site1_v20160810172703.zip" -declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="IisApp",match="^C:\\mySites\\site1",defaultValue="Default Web Site/",tags=IisApp -declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="setAcl",match="^C:\\mySites\\site1",tags=IisApp', working folder 'C:\mySites\site1'
This is an example manifest custom.xml file, which includes information like the necessary runtime version and authentication permissions that should be set on the site’s root directory. This should be created through Visual Studio with your application; ensure that any site-specific configuration is included according to your use case.
<sitemanifestIisApp path="C:\mySites\site1" managedRuntimeVersion="v4.0" />
<setAcl path="C:\mySites\site1" setAclResourceType="Directory" />
<setAcl path="C:\mySites\site1" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
The output location of the application package, which contains all necessary content, instruction, and configuration files to deploy your application to an IIS server.
A double \\ returned path to the location where content is stored locally; used to transform paths from the local system to the target locations when deployed to an IIS server.
This is the path to the location where your content is stored locally. This is used to transform paths from the local system to where it needs to go when deployed to an IIS server.
The following is an updated version of this command that moves all input/output items under c:\mySites:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:manifest="C:\mySites\ConfigFiles\custom.xml" -dest:package="C:\mySites\packages\AWSDeploymentArchive_itguyian_site1.zip" -declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="IisApp",match="^C:\\mySites\\site1",defaultValue="Default Web Site/",tags=IisApp -declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="setAcl",match="^C:\\mySites\\site1",tags=IisApp', working folder 'C:\mySites\site1'
Instead of creating a package and using a custom.xml file under temp, this command creates a file named AWSDeploymentArchive_site1.zip in c:\mySites\Packages, using custom.xml under c:\mySites\ConfigFiles\custom.xml. This file can then be uploaded to an Elastic Beanstalk environment using any supported method.
Note: "custom.xml" is a copy of "tmpB5DF.tmp" from the example; the name and file extension are updated as part of the process.
.NET Website Project
For a .NET website project, use MSBuild and the Visual Studio Project .csproj file to create an application bundle. The .csproj file is usually at the root directory of the Visual Studio Project (e C:\mySites\site1\WebApplication1.csproj).
For an .NET website project to be properly deployed to Elastic Beanstalk, the DeployIisAppPath parameter must begin with Default Web Site.
The following is an example msbuild command to create an application bundle:
"C:\Program Files (x86)\MSBuild\14.0\Bin\amd64\MSBuild.exe" "C:\mySites\site1\WebApplication1\WebApplication1\WebApplication1.csproj" /t:Package /p:DeployIisAppPath="Default Web Site"
The output application package will be under C:\mySites\Site1\WebApplication1\WebApplication1\obj\Debug\Package and is the file WebApplication1.zip. This can be seen in the msbuild verbose output as well. The value of WebApplication1 throughout will be the name of your project but otherwise follow this outline.
Deploy an application zip file to a new or existing Elastic Beanstalk environment
First, create an AWSDeploy configuration file. The following is example file content with valid values used in this example:
DeploymentPackage = C:\mySites\Packages\AWSDeploymentArchive_site1.zip
AWSProfileName = myAWSAccount
Region = us-east-1
Template = ElasticBeanstalk
UploadBucket = elasticbeanstalk-us-east-1-123456789012
Application.Name = AWSDeployExample-Site1
Environment.Name = AWSDeployExample-Site1
For this example, assume that a file with this content is saved to c:\mySites\Packages\AWSDeployConfigFile.txt.
To publish to a new Elastic Beanstalk environment, use a command similar to the following:
C:\Program Files (x86)\AWS Tools\Deployment Tool\awsdeploy.exe" /w C:\mySites\Packages\AWSDeployConfigFile.txt
To publish as an update to an existing Elastic Beanstalk environment, use the following command:
C:\Program Files (x86)\AWS Tools\Deployment Tool\awsdeploy.exe" /r c:\mySites\Packages\AWSDeployConfigFile.txt
Note: If you prefer, you can use the Elastic Beanstalk console instead of the CLI method included with the AWS Toolkit for Visual Studio by following the instructions at Deploying a New Application Version.
If you continue to experience difficulties, please open a case with the DLT Opscenter using the following contact information: