3

I have two ASP.NET Core Apps (API and UI) in Visual Studio solution, want to deploy to a single AWS Elastic Beanstalk on Linux and use Kestrel server (single URL and different ports). How can I accomplish this?

3
  • Are you OK with doing a single Elastic Beanstalk deployment putting your apps on different URL paths instead of on different ports? Commented Jan 27, 2021 at 6:13
  • Looking for one URL and use different ports. Commented Jan 28, 2021 at 17:58
  • Thank You. Yes, single Elastic Beanstalk deployment putting two apps on different URL paths instead of on different ports work fine. Please advise. Regards, Arkay Commented Jan 30, 2021 at 1:38

1 Answer 1

6

AWS Elastic Beanstalk supports running multiple apps in .NET Core on Linux. Elastic Beanstalk's .NET Core on Linux documentation contains a helpful section on Bundling applications which includes an example zip file containing two applications to be deployed together on one Elastic Beanstalk instance: dotnet-core-linux-multiple-apps.zip.

You can deploy the dotnet-core-linux-multiple-apps.zip file directly to Elastic Beanstalk to see it running. For explicit instructions on how to deploy a zip file to Elastic Beanstalk, see the Tutorial - .NET Core on Linux guide. In your case, you'll want to upload the example dotnet-core-linux-multiple-apps.zip instead of the single app zip that the tutorial references.

Each deployed application will run on the Elastic Beanstalk application server instances on the local ports defined in each application's launchSettings.json file. Note that this file is not visible in either of the example apps contained inside the dotnet-core-linux-multiple-apps.zip archive because those apps were already compiled with the dotnet publish command before being included in the zip file.

The relevant configuration that tells Elastic Beanstalk which paths to map to each running app's local ports is inside the platform/nginx/conf.d/elasticbeanstalk/01_custom.conf file, located inside the dotnet-core-linux-multiple-apps.zip. See the .NET Core on Linux proxy server config documentation for more info on what this file contains. Note that Elastic Beanstalk will, by default, map / to port 5000, so you only need to specify additional reverse proxy mappings for your other apps, assuming one of your apps is configured to run on the default port 5000.

So, to sum up:

  1. Make sure you know which local port each of your apps will run on by looking in each app's launchSettings.json file.

  2. Build each of your .NET Core apps and put them together in one folder which you will zip to create the artifact to deploy to Elastic Beanstalk. For the sake of argument, let's call this folder build.

  3. In your build folder (example name, see above), create a platform/nginx/conf.d/elasticbeanstalk/01_custom.conf file which describes how to map each app's ports to your desired paths.

  4. Zip up your 'build` folder. For help with this step, see the Configure an application source bundle documentation

  5. Deploy your source bundle to Elastic Beanstalk. For help with this step, see the Managing application versions documentation.

Sign up to request clarification or add additional context in comments.

1 Comment

The sample is good but I wonder where is the sample repository to see complete source code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.