Click here to Skip to main content
13,861,604 members
Click here to Skip to main content
Add your own
alternative version


Posted 19 Apr 2017
Licenced CPOL

Deploying multiple web apps to Elastic Beanstalk

, 20 Apr 2017
Rate this:
Please Sign up or sign in to vote.
Deploy an core and mvc app to same beanstalk server


In my organization, we typically install a single web app to a single AWS Elastic Beanstalk server, and that web app is at the root directory [Default Web Site], and the URL ends up being http://instancename.   We wanted to deploy several apps to the same box, and thus have http://instancename/app1, http://instancename/app2, etc.  

Amazon's blog : shows a screen shot of example "amazing front end" and "amazing admin" sites, but no sample code.  I will present a core and classic mvc website, deployed to the same amazon instancename, with working example code. 

Using the code

Refer to prerequisite in "points of interest" below.  

Run visual studio 2015

New web project, .net core, create application called "core", and save to desktop folder.

Run visual studio developer command prompt

C:\Users\username\Desktop\Core\CoreApp\src\CoreApp>dotnet run coreapp

Visit http://localhost:5000 in my browser, to verify it works. 

Right click, and deploy to my EB instance, as

Verify that it works.

Make a new ASP app, using online template “Dynamic MVC”, added to desktop folder "Asp".

Right click, and deploy to my EB instance, as

Verify that it works.

Amazon's example says to deploy the .net core app, and "bring along" the associated app.  I therefore choose the core app to be "the parent project" to deploy, and the asp app to be “the child project”.

Default visual studio deploy behavior will try to deploy a global web config with a url rewrite section.  This following step will override this behavior. 

Unload each project by right clicking the project name in visual studio, clicking "unload", and right clicking again, and clicking "Edit project". In the first <PropertyGroup> you see, insert the following line.  You may refer to the enclosed application csproj raw xml to see how it was done in the example app. 

<DeployIISAppPath>Default Web Site/sitename</DeployIISAppPath>

Per the article, add the manifest. 

Add a json formatted file, named “aws-windows-deployment-manifest.json”, to the root directory of the Core csproj. The .net core portion, Core, will be designated in the first section “aspNetCoreWeb”.  The classic asp portion, Asp, will be designated in the msDeploy section, in zip file format.  My manifest, much like Amazon's example, in the enclosed example application, is shown below.  For more manifest information, consult their site: 

  "manifestVersion": 1,
  "deployments": {
    "aspNetCoreWeb": [
        "name": "Core",
        "parameters": {
          "appBundle": "./Core",
          "iisPath": "/Core"

    "msDeploy": [
        "name": "Asp",
        "parameters": {
          "appBundle": "",
          "iisPath": "/Asp"

Make the powershell as described in the article.  Create a .ps1 file as follows.   In my example, I add the .ps1 file to the "core" project for housekeeping purposes, but it is not necessary.  After all is done, I will be adding all the files to source control, so why not put the deploy script in with the solution you will be deploying?

Go to the directory where the .net core site resides in the source tree, to do dotnet publish.

set-location C:\Users\username\Desktop\Core\CoreApp\src\CoreApp

$publishFolder = "c:\temp\publish"

$publishWorkspace = [System.IO.Path]::Combine($publishFolder, "workspace")

If (Test-Path $publishWorkspace){
       Remove-Item $publishWorkspace -Confirm:$false -Force

$appBundle = [System.IO.Path]::Combine($publishFolder, "")

If (Test-Path $appBundle){
       Remove-Item $appBundle -Confirm:$false -Force

Do the dotnet publish.

Write-Host 'Publish the ASP.NET Core frontend' 

$publishFrontendFolder = [System.IO.Path]::Combine($publishWorkspace, "Core")

write-host $publishFrontendFolder

dotnet publish .\project.json -o $publishFrontendFolder -c Release

MSBuild creates the zipped package for Asp.  Note the path specified is relative to the Core project directory.  Let's be real.  In an organization, you very well have the various web site solutions in different parts of your source tree; rarely will you have all websites going to a common server all wrapped within the same solution.   So just make your relative path have the right number of ..\..\ in there to reference the other websites to publish.

Write-Host 'Create msdeploy archive for Asp'

msbuild   ..\..\..\Desktop\Core\CoreApp\src\CoreApp.csproj /t:package /p:Configuration=Release

Copy-Item ..\..\..\Desktop\Core\CoreApp\obj\Release\Package\ $publishWorkspace

The project manifest we created gets copied to the publish folder, along with the two zip files we made from dotnet publish and msbuild.

Write-Host 'Copy deployment manifest'

Copy-Item .\aws-windows-deployment-manifest.json $publishWorkspace

Write-Host 'Zipping up publish workspace to create app bundle'

Add-Type -assembly ""

[io.compression.zipfile]::CreateFromDirectory( $publishWorkspace, $appBundle)

Amazon shows more powershell steps to automate the deploy of the zip we are about to deploy.   However, you can manually deploy the zip file you just made. 

Log in to your amazon console,

In the “all services” section, click on “elastic beanstalk”, and navigate to your target server.   In the "Overview" section, click the "Upload and deploy" button, choose your, and deploy. 

Points of Interest

Important prerequisite, which I learned the hard way:   Start with a perfectly clean install of IIS on your AWS instance.  If your server has some apps installed, no problem: just be sure that no web app resides at the root:  "default web site" or "c:\inetpub\wwwroot".    

If you just right click a web app in visual studio, and publish to elastic beanstalk, as the default website on your AWS instance, it will put your code in this default website.   If you then follow that app by installing to instancename\site1,  you'll get a misleading error message saying you have a duplicate script handler section in web config.  


While working this out, and communicating my progress with Amazon support, they admitted the "amazing front end" was indeed only a screen shot.  I gave them the enclosed source to use as an example in their online help / documentation, and they liked it, and might publish it!   You can say you saw it HERE first! :)


20170419  Initial revision


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Kurt Swendson
Software Developer (Senior) Ellie Mae
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 20 Apr 2017
Article Copyright 2017 by Kurt Swendson
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid