AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Running Multiple Applications and ASP.NET Core Applications with a Deployment Manifest

You can use a deployment manifest to tell Elastic Beanstalk how to deploy your application. For example, instead of using MSDeploy to generate a source bundle for a single ASP.NET application that runs at the root path of your website, you can use a manifest file to run multiple applications at different paths, or tell Elastic Beanstalk to deploy and run the app with ASP.NET Core. You can also use a deployment manifest to configure an application pool in which to run your applications.

Deployment manifests add support for .NET Core applications to Elastic Beanstalk. You can deploy a .NET Standard application without a deployment manifest, but .NET Core applications require a deployment manifest to run on Elastic Beanstalk. When you use a deployment manifest, you create a site archive for each application and then bundle the site archives in a second ZIP archive that contains the deployment manifest.

Deployment manifests also add the ability to run multiple applications at different paths. A deployment manifest defines an array of deployment targets, each with a site archive and a path at which IIS should run it. For example, you could run a web API at the /api path to serve asynchronous requests, and a web app at the root path that consumes the API.

You can also use a deployment manifest to create application pools in IIS in which to run one or more applications. You can configure an application pool to restart your applications periodically, run 32-bit applications, or use a specific version of the .NET Framework runtime.

For full customization, you can write your own deployment scripts in Windows PowerShell and tell Elastic Beanstalk which scripts to run to install, uninstall, and restart your application.

Deployment manifests and related features require a Windows Server platform configuration version 1.2.0 or newer.

.NET Core Apps

You can use a deployment manifest to run .NET Core applications on Elastic Beanstalk. .NET Core is a cross-platform version of .NET that comes with a commandline tool (dotnet) that you can use to generate an application, run it locally, and prepare it for publishing.

Note

See Deploying an ASP.NET Core Application with AWS Elastic Beanstalk for a tutorial and sample application that use a deployment manifest to run a .NET Core application on Elastic Beanstalk.

To run a .NET Core application on Elastic Beanstalk, run dotnet publish and package the output in a ZIP archive, not including any containing directories. Place the site archive in a source bundle with a deployment manifest with a deployment target of type aspNetCoreWeb.

The following deployment manifest runs a .NET Core application from a site archive named dotnet-core-app.zip at the root path.

Example aws-windows-deployment-manifest.json - .NET Core

{
  "manifestVersion": 1,
  "deployments": {
    "aspNetCoreWeb": [
      {
        "name": "my-dotnet-core-app",
        "parameters": {
          "archive": "dotnet-core-app.zip",
          "iisPath": "/"
        }
      }
    ]
  }
}

Bundle the manifest and site archive in a ZIP archive to create a source bundle.

Example dotnet-core-bundle.zip

.
|-- aws-windows-deployment-manifest.json
`-- dotnet-core-app.zip

The site archive contains the compiled application code, dependencies, and web.config file.

Example dotnet-core-app.zip

.
|-- Microsoft.AspNetCore.Hosting.Abstractions.dll
|-- Microsoft.AspNetCore.Hosting.Server.Abstractions.dll
|-- Microsoft.AspNetCore.Hosting.dll
|-- Microsoft.AspNetCore.Http.Abstractions.dll
|-- Microsoft.AspNetCore.Http.Extensions.dll
|-- Microsoft.AspNetCore.Http.Features.dll
|-- Microsoft.AspNetCore.Http.dll
|-- Microsoft.AspNetCore.HttpOverrides.dll
|-- Microsoft.AspNetCore.Server.IISIntegration.dll
|-- Microsoft.AspNetCore.Server.Kestrel.dll
|-- Microsoft.AspNetCore.WebUtilities.dll
|-- Microsoft.Extensions.Configuration.Abstractions.dll
|-- Microsoft.Extensions.Configuration.EnvironmentVariables.dll
|-- Microsoft.Extensions.Configuration.dll
|-- Microsoft.Extensions.DependencyInjection.Abstractions.dll
|-- Microsoft.Extensions.DependencyInjection.dll
|-- Microsoft.Extensions.FileProviders.Abstractions.dll
|-- Microsoft.Extensions.FileProviders.Physical.dll
|-- Microsoft.Extensions.FileSystemGlobbing.dll
|-- Microsoft.Extensions.Logging.Abstractions.dll
|-- Microsoft.Extensions.Logging.dll
|-- Microsoft.Extensions.ObjectPool.dll
|-- Microsoft.Extensions.Options.dll
|-- Microsoft.Extensions.PlatformAbstractions.dll
|-- Microsoft.Extensions.Primitives.dll
|-- Microsoft.Net.Http.Headers.dll
|-- System.Diagnostics.Contracts.dll
|-- System.Net.WebSockets.dll
|-- System.Text.Encodings.Web.dll
|-- dotnet-core-app.deps.json
|-- dotnet-core-app.dll
|-- dotnet-core-app.pdb
|-- dotnet-core-app.runtimeconfig.json
`-- web.config

See the tutorial for a full example.

Run Multiple Applications

You can run multiple applications with a deployment manifest by defining multiple deployment targets.

The following deployment manifest runs a .NET Standard web application at the root path using MS Deploy, and an ASP.NET Core web application at /admin. The front-end web application is a standard MS Deploy source bundle named webapp.zip, and the admin application is a .NET Core site archive named admin.zip.

Example aws-windows-deployment-manifest.json - multiple apps

{
  "manifestVersion": 1,
  "deployments": 
  {
    "msDeploy":
    [{
      "name": "Web app",
      "parameters":
      {
        "appBundle": "webapp.zip",
        "iisPath": "/",
        "iisWebSite": "Default Web Site"
      }
    }],
    "aspNetCoreWeb":
    [{
      "name": "Admin app",
      "parameters": 
      {
        "appBundle": "admin.zip",
        "iisPath": "/admin",
        "iisWebSite": "Default Web Site"
      }
    }]
  }
}

A sample application with multiple applications is available here:

Configure Application Pools

You can use a deployment manifest to configure an application pool in IIS and use it to run one or more applications.

The following deployment manifest configures an application pool that restarts its applications every 10 minutes, and attaches it to a .NET Standard web application that runs at the root path.

Example aws-windows-deployment-manifest.json - app pool

{
  "manifestVersion": 1,
  "iisConfig": {
    "appPools": [
      {
        "name": "App pool",
        "recycling": {
          "regularTimeInterval": 10
        }
      }
    ]
  },
  "deployments": {
    "msDeploy": [
      {
        "name": "Web app",
        "parameters": {
          "archive": "site.zip",
          "iisPath": "/",
          "appPool": "MyPool"
        }
      }
    ]
  }
}

The appPools block under iisConfig defines the application pool.

Each deployment in the deployments block specifies an archive, a path to run it at, and an appPool in which to run it.

Define Custom Deployments

For even more control, you can completely customize an application deployment by defining a custom deployment.

The following deployment manifest tells Elastic Beanstalk to run an install script named siteInstall.ps1 to install the website during instance launch and deployments, run an uninstall script prior to installing a new version during a deployment, and a restart script to restart the application when you choose Restart App Server in the management console.

Example aws-windows-deployment-manifest.json - custom deployment

{
  "manifestVersion": 1,
  "deployments": {
    "custom": [
      {
        "name": "Custom site",
        "scripts": {
          "install": {
            "file": "siteInstall.ps1"
          },
          "restart": {
            "file": "siteRestart.ps1"
          },
          "uninstall": {
            "file": "siteUninstall.ps1"
          }
        }
      }
    ]
  }
}

Include any artifacts required to run the application in your source bundle with the manifest and scripts.

Example custom-site-bundle.zip

.
|-- aws-windows-deployment-manifest.json
|-- siteInstall.ps1
|-- siteRestart.ps1
|-- siteUninstall.ps1
`-- site-contents.zip