

# Deploying .NET core (Linux) applications with Elastic Beanstalk
Deploying .NET core (Linux)

**Check out the *.NET on Amazon Developer Center***  
  
Have you stopped by our *.Net Developer Center*? It's our one stop shop for all things .NET on Amazon.  
For more information see the [.NET on Amazon Developer Center](https://www.amazonaws.cn/developer/language/net).

This chapter provides instructions for configuring and deploying your .NET core (Linux) web application to Amazon Elastic Beanstalk. Elastic Beanstalk makes it easy to deploy, manage, and scale your .NET core (Linux) web applications using Amazon Web Services.

You can deploy your application in just a few minutes using the Elastic Beanstalk Command Line Interface (EB CLI) or by using the Elastic Beanstalk console. After you deploy your Elastic Beanstalk application, you can continue to use the EB CLI to manage your application and environment, or you can use the Elastic Beanstalk console, Amazon CLI, or the APIs.

Follow the steps in the [QuickStart for .NET Core on Linux](dotnet-linux-quickstart.md) for step-by-step instructions to create and deploy an ASP.NET Core *Hello World* web application with the EB CLI.

**Topics**
+ [

# QuickStart: Deploy a .NET Core on Linux application to Elastic Beanstalk
](dotnet-linux-quickstart.md)
+ [

# Setting up your .NET core on Linux development environment for Elastic Beanstalk
](dotnet-linux-devenv.md)
+ [

# Using the Elastic Beanstalk .NET core on Linux platform
](dotnet-linux-platform.md)
+ [

# The Amazon Toolkit for Visual Studio - Working with .Net Core on Elastic Beanstalk
](dotnet-toolkit-linux.md)
+ [

# Migrating from .NET on Windows Server platform to the .NET Core on Linux platform on Elastic Beanstalk
](dotnet-linux-migration.md)

# QuickStart: Deploy a .NET Core on Linux application to Elastic Beanstalk
QuickStart for .NET Core on Linux

This QuickStart tutorial walks you through the process of creating a .NET Core on Linux application and deploying it to an Amazon Elastic Beanstalk environment.

**Not for production use**  
Examples are intended for demonstration only. Do not use example applications in production.

**Topics**
+ [

## Your Amazon account
](#dotnet-linux-quickstart-aws-account)
+ [

## Prerequisites
](#dotnet-linux-quickstart-prereq)
+ [

## Step 1: Create a .NET Core on Linux application
](#dotnet-linux-quickstart-create-app)
+ [

## Step 2: Run your application locally
](#dotnet-linux-quickstart-run-local)
+ [

## Step 3: Deploy your .NET Core on Linux application with the EB CLI
](#dotnet-linux-quickstart-deploy)
+ [

## Step 4: Run your application on Elastic Beanstalk
](#dotnet-linux-quickstart-run-eb-ap)
+ [

## Step 5: Clean up
](#go-tutorial-cleanup)
+ [

## Amazon resources for your application
](#dotnet-linux-quickstart-eb-resources)
+ [

## Next steps
](#dotnet-linux-quickstart-next-steps)
+ [

## Deploy with the Elastic Beanstalk console
](#dotnet-linux-quickstart-console)

## Your Amazon account


If you're not already an Amazon customer, you need to create an Amazon account. Signing up enables you to access Elastic Beanstalk and other Amazon services that you need.

If you already have an Amazon account, you can move on to [Prerequisites](#dotnet-linux-quickstart-prereq).

### Create an Amazon account


#### Sign up for an Amazon Web Services account


If you do not have an Amazon Web Services account, use the following procedure to create one.

**To sign up for Amazon Web Services**

1. Open [http://www.amazonaws.cn/](http://www.amazonaws.cn/) and choose **Sign Up**.

1. Follow the on-screen instructions.

Amazon sends you a confirmation email after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to [http://www.amazonaws.cn/](http://www.amazonaws.cn/) and choosing **My Account**.

#### Secure IAM users


After you sign up for an Amazon Web Services account, safeguard your administrative user by turning on multi-factor authentication (MFA). For instructions, see [Enable a virtual MFA device for an IAM user (console)](https://docs.amazonaws.cn/IAM/latest/UserGuide/id_credentials_mfa_enable_virtual.html#enable-virt-mfa-for-iam-user) in the *IAM User Guide*.

To give other users access to your Amazon Web Services account resources, create IAM users. To secure your IAM users, turn on MFA and only give the IAM users the permissions needed to perform their tasks.

For more information about creating and securing IAM users, see the following topics in the *IAM User Guide*: 
+ [Creating an IAM user in your Amazon Web Services account](https://docs.amazonaws.cn//IAM/latest/UserGuide/id_users_create.html)
+ [Access management for Amazon resources](https://docs.amazonaws.cn/IAM/latest/UserGuide/access.html)
+ [Example IAM identity-based policies](https://docs.amazonaws.cn/IAM/latest/UserGuide/access_policies_examples.html)

## Prerequisites


To follow the procedures in this guide, you will need a command line terminal or shell to run commands. Commands are shown in listings preceded by a prompt symbol (\$1) and the name of the current directory, when appropriate.

```
~/eb-project$ this is a command
this is output
```

On Linux and macOS, you can use your preferred shell and package manager. On Windows you can [install the Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash.

### EB CLI


This tutorial uses the Elastic Beanstalk Command Line Interface (EB CLI). For details on installing and configuring the EB CLI, see [Install EB CLI with setup script (recommended)](eb-cli3.md#eb-cli3-install) and [Configure the EB CLI](eb-cli3-configuration.md).

### .NET Core on Linux


If you don't have the .NET SDK installed on your local machine, you can install it by following the [Download .NET](https://dotnet.microsoft.com/en-us/download) link on the [.NET documentation](https://learn.microsoft.com/en-us/dotnet/) website.

Verify your .NET SDK installation by running the following command.

```
~$ dotnet --info
```

## Step 1: Create a .NET Core on Linux application


Create a project directory.

```
~$ mkdir eb-dotnetcore
~$ cd eb-dotnetcore
```

Next, create a sample Hello World application by running the following commands.

```
~/eb-dotnetcore$ dotnet new web --name HelloElasticBeanstalk
~/eb-dotnetcore$ cd HelloElasticBeanstalk
```

## Step 2: Run your application locally


Run the following command to run your application locally.

```
~/eb-dotnetcore/HelloElasticBeasntalk$ dotnet run
```

The output should look something like the following text.

```
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7294
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5052
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
```

**Note**  
The `dotnet` command selects a port at random when running the application locally. In this example the port is 5052. When you deploy the application to your Elastic Beanstalk environment, the application will run on port 5000.

Enter the URL address `http://localhost:port` in your web browser. For this specific example, the command is `http://localhost:5052`. The web browser should display “Hello World\$1”.

## Step 3: Deploy your .NET Core on Linux application with the EB CLI


Run the following commands to create an Elastic Beanstalk environment for this application.

 

**To create an environment and deploy your .NET Core on Linux application**

1. Compile and publish your application to a folder for deployment to the Elastic Beanstalk environment you're about to create.

   ```
   ~$ cd eb-dotnetcore/HelloElasticBeanstalk
   ~/eb-dotnetcore/HelloElasticBeanstalk$ dotnet publish -o site
   ```

1. Navigate to the site directory where you just published your app.

   ```
   ~/eb-dotnetcore/HelloElasticBeanstalk$ cd site
   ```

1. Initialize your EB CLI repository with the **eb init** command.

   Be aware of the following details regarding the platform branch version that you specify in the command:
   + Replace `x.y.z` in the following command with the latest version of the platform branch *.NET 6 on AL2023*.
   + To locate the latest platform branch version see [.NET Core on Linux](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.dotnetlinux) *Supported platforms* in the *Amazon Elastic Beanstalk Platforms* guide.
   + An example of a solution stack name that includes the version number is `64bit-amazon-linux-2023-v3.1.1-running-.net-6`. In this example the branch version is *3.1.1*.

   ```
   ~eb-dotnetcore/HelloElasticBeanstalk/site$ eb init -p 64bit-amazon-linux-2023-vx.y.z-running-.net-6 dotnetcore-tutorial --region us-west-2
   Application dotnetcore-tutorial has been created.
   ```

   This command creates an application named `dotnetcore-tutorial` and configures your local repository to create environments with the .NET Core on Linux platform version specified in the command.

1. (Optional) Run **eb init** again to configure a default key pair so that you can use SSH to connect to the EC2 instance running your application.

   ```
   ~eb-dotnetcore/HelloElasticBeanstalk/site$ eb init
   Do you want to set up SSH for your instances?
   (y/n): y
   Select a keypair.
   1) my-keypair
   2) [ Create new KeyPair ]
   ```

   Select a key pair if you have one already, or follow the prompts to create one. If you don't see the prompt or need to change your settings later, run **eb init -i**.

1. Create an environment and deploy your application to it with **eb create**. Elastic Beanstalk automatically builds a zip file for your application and starts it on port 5000.

   to 

   ```
   ~eb-dotnetcore/HelloElasticBeanstalk/site$ eb create dotnet-tutorial
   ```

   It takes about five minutes for Elastic Beanstalk to create your environment.

## Step 4: Run your application on Elastic Beanstalk


When the process to create your environment completes, open your website with **eb open**.

```
~eb-dotnetcore/HelloElasticBeanstalk/site$ eb open
```

Congratulations\$1 You've deployed a .NET Core on Linux application with Elastic Beanstalk\$1 This opens a browser window using the domain name created for your application.

## Step 5: Clean up


You can terminate your environment when you finish working with your application. Elastic Beanstalk terminates all Amazon resources associated with your environment.

To terminate your Elastic Beanstalk environment with the EB CLI run the following command.

```
~eb-dotnetcore/HelloElasticBeanstalk/site$ eb terminate
```

## Amazon resources for your application


You just created a single instance application. It serves as a straightforward sample application with a single EC2 instance, so it doesn't require load balancing or auto scaling. For single instance applications Elastic Beanstalk creates the following Amazon resources:
+ **EC2 instance** – An Amazon EC2 virtual machine configured to run web apps on the platform you choose.

  Each platform runs a different set of software, configuration files, and scripts to support a specific language version, framework, web container, or combination thereof. Most platforms use either Apache or nginx as a reverse proxy that processes web traffic in front of your web app, forwards requests to it, serves static assets, and generates access and error logs.
+ **Instance security group** – An Amazon EC2 security group configured to allow incoming traffic on port 80. This resource lets HTTP traffic from the load balancer reach the EC2 instance running your web app. By default, traffic is not allowed on other ports.
+ **Amazon S3 bucket** – A storage location for your source code, logs, and other artifacts that are created when you use Elastic Beanstalk.
+ **Amazon CloudWatch alarms** – Two CloudWatch alarms that monitor the load on the instances in your environment and are triggered if the load is too high or too low. When an alarm is triggered, your Auto Scaling group scales up or down in response.
+ **Amazon CloudFormation stack** – Elastic Beanstalk uses Amazon CloudFormation to launch the resources in your environment and propagate configuration changes. The resources are defined in a template that you can view in the [Amazon CloudFormation console](https://console.amazonaws.cn/cloudformation).
+  **Domain name** – A domain name that routes to your web app in the form **subdomain*.*region*.eb.amazonaws.com.cn*. 

Elastic Beanstalk manages all of these resources. When you terminate your environment, Elastic Beanstalk terminates all the resources that it contains.

## Next steps


After you have an environment running an application, you can deploy a new version of the application or a different application at any time. Deploying a new application version is very quick because it doesn't require provisioning or restarting EC2 instances. You can also explore your new environment using the Elastic Beanstalk console. For detailed steps, see [Explore your environment](GettingStarted.md#GettingStarted.Explore) in the *Getting started* chapter of this guide.

After you deploy a sample application or two and are ready to start developing and running .NET Core on Linux applications locally, see [Setting up your .NET core on Linux development environment for Elastic Beanstalk](dotnet-linux-devenv.md). 

## Deploy with the Elastic Beanstalk console
Deploy with the console

You can also use the Elastic Beanstalk console to launch the sample application. For detailed steps, see [Create an example application](GettingStarted.md#GettingStarted.CreateApp) in the *Getting started* chapter of this guide.

# Setting up your .NET core on Linux development environment for Elastic Beanstalk
Development environment

This topic provides instructions to set up a .NET core on Linux development environment to test your application locally prior to deploying it to Amazon Elastic Beanstalk. It also references websites that provide installation instructions for useful tools. 

**Topics**
+ [

## Installing the .NET Core SDK
](#dotnet-linux-devenv-dotnetcore)
+ [

## Installing an IDE
](#dotnet-devenv-ide)
+ [

## Installing the Amazon Toolkit for Visual Studio
](#dotnet-devenv-toolkit)

## Installing the .NET Core SDK


You can use the .NET Core SDK to develop applications that run on Linux.

See the [.NET downloads page](https://dotnet.microsoft.com/download) to download and install the .NET Core SDK.

## Installing an IDE


Integrated development environments (IDEs) provide a range of features that facilitate application development. If you haven't used an IDE for .NET development, try Visual Studio Community to get started.

See the [Visual Studio Community](https://www.visualstudio.com/vs/community/) page to download and install Visual Studio Community.

## Installing the Amazon Toolkit for Visual Studio


The [Amazon Toolkit for Visual Studio](dotnet-toolkit.md) is an open source plugin for the Visual Studio IDE that makes it easier for developers to develop, debug, and deploy .NET applications using Amazon. See the [Toolkit for Visual Studio homepage](http://www.amazonaws.cn/visualstudio/) for installation instructions.

# Using the Elastic Beanstalk .NET core on Linux platform
The .NET core on Linux platform

This topic describes how to configure, build, and run your .NET core on Linux applications on Elastic Beanstalk.

Amazon Elastic Beanstalk supports a number of platform branches for different .NET Core framework versions that run on the Linux operating system. See [.NET core on Linux ](https://docs.amazonaws.cn/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.dotnetlinux) in the *Amazon Elastic Beanstalk Platforms* for a full list.

For details about the various ways you can extend an Elastic Beanstalk Linux-based platform, see [Extending Elastic Beanstalk Linux platforms](platforms-linux-extend.md). 

## .NET Core on Linux platform considerations


### Proxy server


The Elastic Beanstalk .NET Core on Linux platform includes a reverse proxy that forwards requests to your application. By default, Elastic Beanstalk uses [NGINX](https://www.nginx.com/) as the proxy server. You can choose to use no proxy server, and configure [Kestrel](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel) as your web server. Kestrel is included by default in ASP.NET Core project templates.

### Application structure


You can publish *runtime-dependent* applications that use the .NET Core runtime provided by Elastic Beanstalk. You can also publish *self-contained* applications that include the .NET Core runtime and your application's dependencies in the source bundle. To learn more, see [Bundling applications for the .NET Core on Linux Elastic Beanstalk platform](dotnet-linux-platform-bundle-app.md).

### Platform configuration


To configure the processes that run on the server instances in your environment, include an optional [Procfile](dotnet-linux-procfile.md) in your source bundle. A `Procfile` is required if you have more than one application in your source bundle.

We recommend that you always provide a `Procfile` in the source bundle with your application. This way you precisely control which processes Elastic Beanstalk runs for your application.

Configuration options are available in the Elastic Beanstalk console for [modifying the configuration of a running environment](environment-configuration-methods-after.md). To avoid losing your environment's configuration when you terminate it, you can use [saved configurations](environment-configuration-savedconfig.md) to save your settings and later apply them to another environment.

To save settings in your source code, you can include [configuration files](ebextensions.md). Settings in configuration files are applied every time you create an environment or deploy your application. You can also use configuration files to install packages, run scripts, and perform other instance customization operations during deployments.

Settings applied in the Elastic Beanstalk console override the same settings in configuration files, if they exist. This lets you have default settings in configuration files, and override them with environment-specific settings in the console. For more information about precedence, and other methods of changing settings, see [Configuration options](command-options.md).

## Configuring your .NET Core on Linux environment


The .NET Core on Linux platform settings enable you to fine-tune the behavior of your Amazon EC2 instances. You can edit the Elastic Beanstalk environment's Amazon EC2 instance configuration using the Elastic Beanstalk console.

Use the Elastic Beanstalk console to enable log rotation to Amazon S3 and configure variables that your application can read from the environment.

**To configure your .NET Core on Linux environment using the Elastic Beanstalk console**

1. Open the [Elastic Beanstalk console](https://console.amazonaws.cn/elasticbeanstalk), and in the **Regions** list, select your Amazon Web Services Region.

1. In the navigation pane, choose **Environments**, and then choose the name of your environment from the list.

1. In the navigation pane, choose **Configuration**.

1. In the **Updates, monitoring, and logging** configuration category, choose **Edit**.

### Log options


The **Log Options** section has two settings:
+ **Instance profile** – Specifies the instance profile that has permission to access the Amazon S3 bucket associated with your application.
+ **Enable log file rotation to Amazon S3** – Specifies whether log files for your application's Amazon EC2 instances are copied to the Amazon S3 bucket associated with your application.

### Environment properties


The **Environment Properties** section enables you to specify environment configuration settings on the Amazon EC2 instances that are running your application. Environment properties are passed in as key-value pairs to the application.

Inside the .NET Core on Linux environment running in Elastic Beanstalk, environment variables are accessible using `Environment.GetEnvironmentVariable("variable-name")`. For example, you could read a property named `API_ENDPOINT` to a variable with the following code.

```
string endpoint = Environment.GetEnvironmentVariable("API_ENDPOINT");
```

See [Environment variables and other software settings](environments-cfg-softwaresettings.md) for more information.

## .NET Core on Linux configuration namespace


You can use a [configuration file](ebextensions.md) to set configuration options and perform other instance configuration tasks during deployments. Configuration options can be [platform specific](command-options-specific.md) or apply to [all platforms](command-options-general.md) in the Elastic Beanstalk service as a whole. Configuration options are organized into *namespaces*.

The .NET Core on Linux platform supports options in the following namespace, in addition to the [options supported for all Elastic Beanstalk environments](command-options-general.md):
+ `aws:elasticbeanstalk:environment:proxy` – Choose to use NGINX or no proxy server. Valid values are `nginx` or `none`.

The following example configuration file shows the use of the .NET Core on Linux-specific configuration options. 

**Example .ebextensions/proxy-settings.config**  

```
option_settings:
  aws:elasticbeanstalk:environment:proxy:
    ProxyServer: none
```

Elastic Beanstalk provides many configuration options for customizing your environment. In addition to configuration files, you can also set configuration options using the console, saved configurations, the EB CLI, or the Amazon CLI. See [Configuration options](command-options.md) for more information.

# Bundling applications for the .NET Core on Linux Elastic Beanstalk platform
Bundling applications

You can run both *runtime-dependent* and *self-contained* .NET Core applications on Amazon Elastic Beanstalk.

A runtime-dependent application uses a .NET Core runtime that Elastic Beanstalk provides to run your application. Elastic Beanstalk uses the `runtimeconfig.json` file in your source bundle to determine the runtime to use for your application. Elastic Beanstalk chooses the latest compatible runtime available for your application.

A self-contained application includes the .NET Core runtime, your application, and its dependencies. To use a version of the .NET Core runtime that Elastic Beanstalk doesn't include in its platforms, provide a self-contained application.

## Examples


You can compile both self-contained and runtime-dependent applications with the `dotnet publish` command. To learn more about publishing .NET Core apps, see [.NET Core application publishing overview](https://docs.microsoft.com/en-us/dotnet/core/deploying) in the .NET Core documentation.

The following example file structure defines a single application that uses a .NET Core runtime that Elastic Beanstalk provides.

```
├── appsettings.Development.json
├── appsettings.json
├── dotnetcoreapp.deps.json
├── dotnetcoreapp.dll
├── dotnetcoreapp.pdb
├── dotnetcoreapp.runtimeconfig.json
├── web.config
├── Procfile
├── .ebextensions
├── .platform
```

You can include multiple applications in your source bundle. The following example defines two applications to run on the same web server. To run multiple applications, you must include a [Procfile](dotnet-linux-procfile.md) in your source bundle. For a full example application, see [dotnet-core-linux-multiple-apps.zip](samples/dotnet-core-linux-multiple-apps.zip).

```
├── DotnetMultipleApp1
│   ├── Amazon.Extensions.Configuration.SystemsManager.dll
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   ├── AWSSDK.Core.dll
│   ├── AWSSDK.Extensions.NETCore.Setup.dll
│   ├── AWSSDK.SimpleSystemsManagement.dll
│   ├── DotnetMultipleApp1.deps.json
│   ├── DotnetMultipleApp1.dll
│   ├── DotnetMultipleApp1.pdb
│   ├── DotnetMultipleApp1.runtimeconfig.json
│   ├── Microsoft.Extensions.PlatformAbstractions.dll
│   ├── Newtonsoft.Json.dll
│   └── web.config
├── DotnetMultipleApp2
│   ├── Amazon.Extensions.Configuration.SystemsManager.dll
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   ├── AWSSDK.Core.dll
│   ├── AWSSDK.Extensions.NETCore.Setup.dll
│   ├── AWSSDK.SimpleSystemsManagement.dll
│   ├── DotnetMultipleApp2.deps.json
│   ├── DotnetMultipleApp2.dll
│   ├── DotnetMultipleApp2.pdb
│   ├── DotnetMultipleApp2.runtimeconfig.json
│   ├── Microsoft.Extensions.PlatformAbstractions.dll
│   ├── Newtonsoft.Json.dll
│   └── web.config
├── Procfile
├── .ebextensions
├── .platform
```

# Using a Procfile to configure your .NET Core on Linux Elastic Beanstalk environment
Procfile

To run multiple applications on the same web server, you must include a `Procfile` in your source bundle that tells Elastic Beanstalk which applications to run.

We recommend that you always provide a `Procfile` in the source bundle with your application. This way you precisely control which processes Elastic Beanstalk runs for your application and which arguments these processes receive.

The following example uses a `Procfile` to specify two applications for Elastic Beanstalk to run on the same web server.

**Example Procfile**  

```
web: dotnet ./dotnet-core-app1/dotnetcoreapp1.dll
web2: dotnet ./dotnet-core-app2/dotnetcoreapp2.dll
```

For details about writing and using a `Procfile`, see [Buildfile and Procfile](platforms-linux-extend.build-proc.md).

# Configuring the proxy server
Proxy server

Amazon Elastic Beanstalk uses [NGINX](https://www.nginx.com/) as the reverse proxy to relay requests to your application. Elastic Beanstalk provides a default NGINX configuration that you can either extend or override completely with your own configuration.

By default, Elastic Beanstalk configures the NGINX proxy to forward requests to your application on port 5000. You can override the default port by setting the `PORT` [environment property](dotnet-linux-platform.md#dotnet-linux-options-properties) to the port on which your main application listens.

**Note**  
The port that your application listens on doesn't affect the port that the NGINX server listens on to receive requests from the load balancer.

**Configuring the proxy server on your platform version**  
All AL2023/AL2 platforms support a uniform proxy configuration feature. For more information about configuring the proxy server on your platform versions running AL2023/AL2, see [Reverse proxy configuration](platforms-linux-extend.proxy.md). 

The following example configuration file extends your environment's NGINX configuration. The configuration directs requests to `/api` to a second web application that listens on port 5200 on the web server. By default, Elastic Beanstalk forwards requests to a single application that listens on port 5000.

**Example `01_custom.conf`**  

```
location /api {
     proxy_pass          http://127.0.0.1:5200;
     proxy_http_version  1.1;

     proxy_set_header   Upgrade $http_upgrade;
     proxy_set_header   Connection $http_connection;
     proxy_set_header   Host $host;
     proxy_cache_bypass $http_upgrade;
     proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header   X-Forwarded-Proto $scheme;
}
```

# The Amazon Toolkit for Visual Studio - Working with .Net Core on Elastic Beanstalk
The Amazon Toolkit for Visual Studio

This topic shows how you can do the following tasks using the Amazon Toolkit for Visual Studio:
+ Create an ASP.NET Core web application using a Visual Studio template.
+ Create an Elastic Beanstalk Amazon Linux environment.
+ Deploy the ASP.NET Core web application to the new Amazon Linux environment.

This topic also explores how you can use the Amazon Toolkit for Visual Studio to manage your Elastic Beanstalk application environments and monitor your application's health.

The Amazon Toolkit for Visual Studio is a plugin to the Visual Studio IDE. With the toolkit you can deploy and manage applications in Elastic Beanstalk while you are working in your Visual Studio environment.

**Topics**
+ [

## Prerequisites
](#dotnet-toolkit-linux-core-tutorial-prereqs)
+ [

## Create a new application project
](#dotnet-toolkit-linux-core-tutorial-create-project)
+ [

## Create an Elastic Beanstalk environment and deploy your application
](#dotnet-toolkit-linux-core-tutorial-create-env-and-deploy)
+ [

## Terminating an environment
](#dotnet-toolkit-linux-core-tutorial-terminate-env)
+ [

# Managing your Elastic Beanstalk application environments
](create_deploy_NET-linux.managing.md)
+ [

# Monitoring application health
](create_deploy_NET-linux.healthstatus.md)

## Prerequisites


Before you begin this tutorial, you need to install the Amazon Toolkit for Visual Studio. For instructions, see [Setting up the Amazon Toolkit for Visual Studio](https://docs.amazonaws.cn/toolkit-for-visual-studio/latest/user-guide/getting-set-up.html).

If you have never used the toolkit before, the first thing you'll need to do after installing the toolkit is to register your Amazon credentials with the toolkit. For more information about this, see [Providing Amazon Credentials](https://docs.amazonaws.cn/toolkit-for-visual-studio/latest/user-guide/credentials.html).

## Create a new application project


If you don't have a .NET Core application project in Visual Studio, you can easily create one using one of the Visual Studio project templates.

**To create a new ASP.NET Core web application project**

1. In Visual Studio, on the **File** menu, choose **New** and then choose **Project**.

1. In the **Create a new project** dialog box, select **C\$1**, select **Linux**, and then select **Cloud**.

1. From the list of project templates that displays select **ASP.NET Core Web Application**, and then select **Next**.
**Note**  
If you don't see **ASP.NET Core Web Application** listed in the project templates, you can install it in Visual Studio.  
Scroll to the bottom of the template list and select the **Install more tools and features** link that is located under the template list. 
If you are prompted to allow the Visual Studio application to make changes to your device, select **Yes**.
Choose the **Workloads** tab, then select **ASP.NET and web development. ** 
Select the **Modify** button. The **Visual Studio Installer** installs the project template. 
After the installer completes, exit the panel to return to where you left off in Visual Studio .

1. In the **Configure your new project** dialog box, enter a **Project name**. The **Solution name** defaults to your project name. Next, choose **Create**.

1. In the **Create a new ASP.NET Core web application** dialog box, select **.NET Core**, and then select **ASP.NET Core 3.1**. From the list of application types that are displayed, select **Web Application**, then select the **Create** button.

 Visual Studio displays the **Creating Project** dialog box when it creates your application. After Visual Studio completes generating your application, a panel with your application name is displayed.

## Create an Elastic Beanstalk environment and deploy your application


This section describes how to create an Elastic Beanstalk environment for your application and deploy your application to that environment. 

**To create a new environment and deploy your application**

1.  In Visual Studio select **View**, then **Solution Explorer**. 

1. In **Solution Explorer**, open the context (right-click) menu for your application, and then select **Publish to Amazon Elastic Beanstalk**.

1. In the **Publish to Amazon Elastic Beanstalk** wizard, enter your account information.

   1. For **Account profile to use**, select your **default** account or choose the **Add another account** icon to enter new account information.

   1. For **Region**, select the Region where you want to deploy your application. For information about available Amazon Regions, see [Amazon Elastic Beanstalk Endpoints and Quotas](https://docs.amazonaws.cn/general/latest/gr/elasticbeanstalk.html) in the *Amazon Web Services General Reference*. If you select a Region that is not supported by Elastic Beanstalk, then the option to deploy to Elastic Beanstalk is unavailable.

   1. Select **Create a new application environment**, then choose **Next**.

1. On the **Application Environment** dialog box, enter the details for your new application environment.

1. On the next **Amazon** options dialog box, set Amazon EC2 options and other Amazon related options for your deployed application.

   1. For **Container type** select **64bit Amazon Linux 2 v*<n.n.n>* running .NET Core.** 
**Note**  
We recommend you select the current platform version of Linux. This version contains the most recent security and bug fixes that are included in our latest Amazon Machine Image (AMI). 

   1. For **Instance Type**, select **t2.micro**. (Choosing a micro instance type minimizes the cost associated with running the instance.)

   1. For **Key pair**, select **Create new key pair**. Enter a name for the new key pair, and then choose **OK**. (In this example, we use **myuseastkeypair**.) A key pair enables remote-desktop access to your Amazon EC2 instances. For more information about Amazon EC2 key pairs, see [Using Credentials](http://docs.amazonaws.cn/AWSEC2/latest/UserGuide/using-credentials.html) in the *Amazon Elastic Compute Cloud User Guide*.

   1. For a simple, low traffic application, select **Single instance environment**. For more information, see [Environment types](using-features-managing-env-types.md)

   1. Select **Next**.

    For more information about the Amazon options that are not used in this example consider the following pages: 
   + For** Use custom AMI**, see [Using a custom Amazon machine image (AMI) in your Elastic Beanstalk environment](using-features.customenv.md).
   + If you don't select **Single instance environment**, you need to choose a **Load balance type**. See [Load balancer for your Elastic Beanstalk environment](using-features.managing.elb.md) for more information. 
   + Elastic Beanstalk uses the default [Amazon VPC](https://docs.amazonaws.cn/vpc/latest/userguide/) (Amazon Virtual Private Cloud) configuration if you didn't choose **Use non-default VPC**. For more information see [Using Elastic Beanstalk with Amazon VPC](vpc.md).
   + Choosing the **Enable Rolling Deployments** option splits a deployment into batches to avoid potential downtime during deployments. For more information, see [Deploying applications to Elastic Beanstalk environments](using-features.deploy-existing-version.md).
   + Choosing the **Relational Database Access** option connects your Elastic Beanstalk environment to a previously created Amazon RDS database with *Amazon RDS DB Security Groups*. For more information, see [Controlling Access with Security Groups](https://docs.amazonaws.cn/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html) in the *Amazon RDS User Guide*.

1. Select **Next** on the **Permissions** dialog box.

1. Select **Next** on the **Applications Options** dialog box.

1. Review your deployment options. After you've verified your settings are correct, select **Deploy**.

Your ASP.NET Core web application is exported as a web deploy file. This file is then uploaded to Amazon S3 and registered as a new application version with Elastic Beanstalk. The Elastic Beanstalk deployment feature monitors your environment until it is available with the newly deployed code. The **Status** for your environment is displayed on the Env:<environment name> tab. After the status updates to **Environment is healthy**, you can select the URL address to launch the web application.

## Terminating an environment


 To avoid incurring charges for unused Amazon resources, you can use the Amazon Toolkit for Visual Studio to terminate a running environment.

**Note**  
You can always launch a new environment using the same version later. 

**To terminate an environment**

1. Expand the Elastic Beanstalk node and the application node. In **Amazon Explorer** open the context (right-click) menu for your application environment and select **Terminate Environment**.

1. When prompted, select **Yes** to confirm that you want to terminate the environment. It takes a few minutes for Elastic Beanstalk to terminate the Amazon resources running in the environment. 

The **Status** for your environment on the Env:<environment name> tab changes to **Terminating** and is eventually **Terminated**.

**Note**  
 When you terminate your environment, the CNAME associated with the terminated environment becomes available for anyone to use. 

# Managing your Elastic Beanstalk application environments
Managing environments

This section describes the specific service settings you can edit in the Amazon Toolkit for Visual Studio as part of your application environment configuration. With the Amazon Toolkit for Visual Studio and the Amazon Management Console, you can change the provisioning and configuration of the Amazon resources used by your application environments. For information on how to manage your application environments using the Amazon Management Console, see [Managing Elastic Beanstalk environments](using-features.managing.md).

## Changing environment configurations settings


When you deploy your application, Elastic Beanstalk configures several connected Amazon cloud computing services. You can control how these individual services are configured by using the Amazon Toolkit for Visual Studio.

**To edit an application's environment settings**

1. In Visual Studio, on the **File** menu, choose **Amazon Explorer**.

1. Expand the Elastic Beanstalk node and your application node. Open the context (right-click) menu for your application environment and select **View Status**. 

   You can now configure settings for the following:
   + Amazon X-Ray
   + Server
   + Load Balancer (only applies to multiple-instance environments)
   + Auto Scaling (only applies to multiple-instance environments)
   + Notifications
   + Container
   + Advanced Configuration Options

# Configuring Amazon X-Ray using the Amazon toolkit for Visual Studio
Amazon X-Ray

 Amazon X-Ray provides request tracing, exception collection, and profiling capabilities. With the Amazon X-Ray panel, you can enable or disable X-Ray for your application. For more information about X-Ray, see the [Amazon X-Ray Developer Guide](https://docs.amazonaws.cn/xray/latest/devguide/).

![\[Screenshot of Amazon X-Ray configuration panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-xray-tab.png)


# Configuring EC2 instances using the Amazon toolkit for Visual Studio
EC2 server instances

You can use Amazon Elastic Compute Cloud (Amazon EC2) to launch and manage server instances in Amazon's data centers. You can use Amazon EC2 server instances at any time, for as long as you need, and for any legal purpose. Instances are available in different sizes and configurations. For more information, see [Amazon EC2](http://www.amazonaws.cn/ec2/).

You can edit your Amazon EC2 instance configuration with the **Server** tab inside your application environment tab in the Amazon Toolkit for Visual Studio. 

![\[Screenshot of Porting Assistant for .NET configuration panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-server-tab.png)


## Amazon EC2 instance types


**Instance type** displays the instance types available to your Elastic Beanstalk application. Change the instance type to select a server with the characteristics (including memory size and CPU power) that are most appropriate to your application. For example, applications with intensive and long-running operations can require more CPU or memory.

For more information about the Amazon EC2 instance types available for your Elastic Beanstalk application, see [Instance Types](https://docs.amazonaws.cn/AWSEC2/latest/UserGuide/instance-types.html) in the *Amazon Elastic Compute Cloud User Guide*.

## Amazon EC2 security groups


You can control access to your Elastic Beanstalk application using an *Amazon EC2 Security Group*. A security group defines firewall rules for your instances. These rules specify which incoming network traffic should be delivered to your instance. All other incoming traffic is discarded. You can modify rules for a group at any time. The new rules are automatically enforced for all running instances and instances launched in the future. 

You can specify which Amazon EC2 Security Groups control access to your Elastic Beanstalk application. To do this, enter the names of specific Amazon EC2 security groups (separating multiple secruity groups with commas) into the **EC2 Security Groups** text box. You can do this either by using the Amazon Management Console or the Amazon Toolkit for Visual Studio.

**To create a security group using the Amazon toolkit for Visual Studio**

1.  In Visual Studio, in **Amazon Explorer**, expand the **Amazon EC2** node, and then select **Security Groups**. 

1. Select **Create Security Group**, and enter a name and description for your security group. 

1. Select **OK**. 

For more information on Amazon EC2 Security Groups, see [Using Security Groups](http://docs.amazonaws.cn/AWSEC2/latest/UserGuide/using-network-security.html) in the *Amazon Elastic Compute Cloud User Guide*.

## Amazon EC2 key pairs


You can securely log in to the Amazon EC2 instances provisioned for your Elastic Beanstalk application with an Amazon EC2 key pair.

**Important**  
You must create an Amazon EC2 key pair and configure your Amazon EC2 instances provisioned by Elastic Beanstalk to be able to access these instances. You can create your key pair using the **Publish to Amazon** wizard inside the Amazon Toolkit for Visual Studio when you deploy your application to Elastic Beanstalk. If you want to create additional key pairs using the Toolkit, follow the steps described here. Alternatively, you can set up your Amazon EC2 key pairs using the [Amazon Management Console](https://console.amazonaws.cn/). For instructions on creating a key pair for Amazon EC2, see the [Amazon Elastic Compute Cloud Getting Started Guide](http://docs.amazonaws.cn/AWSEC2/latest/GettingStartedGuide/). 

The **Existing Key Pair** text box lets you specify the name of an Amazon EC2 key pair that you can use to securely log in to the Amazon EC2 instances that are running your Elastic Beanstalk application. 

**To specify the name of an Amazon EC2 key pair**

1. Expand the **Amazon EC2** node and select **Key Pairs**.

1. Select **Create Key Pair** and enter the key pair name. 

1. Select **OK**. 

For more information about Amazon EC2 key pairs, go to [Using Amazon EC2 Credentials](http://docs.amazonaws.cn/AWSEC2/latest/UserGuide/using-credentials.html) in the *Amazon Elastic Compute Cloud User Guide*. For more information about connecting to Amazon EC2 instances, see 

## Monitoring interval


 By default, only basic Amazon CloudWatch metrics are enabled. They return data in five-minute periods. You can enable more granular one-minute CloudWatch metrics by selecting **1 minute** for the **Monitoring Interval** in the **Server** section of the **Configuration** tab for your environment in the Amazon Toolkit for Eclipse.

**Note**  
Amazon CloudWatch service charges can apply for one-minute interval metrics. See [Amazon CloudWatch](http://www.amazonaws.cn/cloudwatch/) for more information.

## Custom AMI ID


 You can override the default AMI used for your Amazon EC2 instances with your own custom AMI by entering the identifier of your custom AMI into the **Custom AMI ID** box in the **Server** section of the **Configuration** tab for your environment in the Amazon Toolkit for Eclipse. 

**Important**  
Using your own AMI is an advanced task that you should do with care. If you need a custom AMI, we recommend you start with the default Elastic Beanstalk AMI and then modify it. To be considered healthy, Elastic Beanstalk expects Amazon EC2 instances to meet a set of requirements, including having a running host manager. If these requirements are not met, your environment might not work properly.

# Configuring Elastic Load Balancing using the Amazon toolkit for Visual Studio
Elastic Load Balancing

Elastic Load Balancing is an Amazon web service that helps you improve the availability and scalability of your application. This service makes it easy for you to distribute application loads between two or more Amazon EC2 instances. Elastic Load Balancing improves availability through providing additional redundancy and supports traffic growth for your application. 

 With Elastic Load Balancing, you can automatically distribute and balance incoming application traffic among all your running instances. You can also easily add new instances when increasing the capacity of your application is required.

 Elastic Beanstalk automatically provisions Elastic Load Balancing when you deploy an application. You can edit the Elastic Beanstalk environment's Amazon EC2 instance configuration with the **Load Balancer** tab inside your application environment tab in Amazon Toolkit for Visual Studio.

![\[Screenshot of Load Balancer configuration panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-loadbalancer.png)


 The following sections describe the Elastic Load Balancing parameters you can configure for your application.

## Ports


The load balancer provisioned to handle requests for your Elastic Beanstalk application sends requests to the Amazon EC2 instances that are running your application. The provisioned load balancer can listen for requests on HTTP and HTTPS ports and route requests to the Amazon EC2 instances in your Amazon Elastic Beanstalk application. By default, the load balancer handles requests on the HTTP port. For this to work, at least one of the ports (either HTTP or HTTPS) must be turned on.

![\[Elastic Beanstalk Elastic Load Balancing configuration - ports\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-loadbalancer-ports.png)


**Important**  
Make sure that the port that you specified is not locked down; otherwise, you won't be able to connect to your Elastic Beanstalk application.

### Controlling the HTTP port


To turn off the HTTP port, select **OFF** for **HTTP Listener Port**. To turn on the HTTP port, you select an HTTP port (for example, **80**) from the list.

**Note**  
To access your environment using a port other than the default port 80, such as port 8080, add a listener to the existing load balancer and configure the new listener to listen on that port.  
For example, using the [Amazon CLI for Classic load balancers](https://docs.amazonaws.cn/cli/latest/reference/elb/create-load-balancer-listeners.html), type the following command, replacing *LOAD\$1BALANCER\$1NAME* with the name of your load balancer for Elastic Beanstalk.  

```
aws elb create-load-balancer-listeners --load-balancer-name LOAD_BALANCER_NAME --listeners "Protocol=HTTP, LoadBalancerPort=8080, InstanceProtocol=HTTP, InstancePort=80"
```
For example, using the [Amazon CLI for Application Load Balancers](https://docs.amazonaws.cn/cli/latest/reference/elbv2/create-listener.html), type the following command, replacing *LOAD\$1BALANCER\$1ARN* with the ARN of your load balancer for Elastic Beanstalk.  

```
aws elbv2 create-listener --load-balancer-arn LOAD_BALANCER_ARN --protocol HTTP --port 8080
```
If you want Elastic Beanstalk to monitor your environment, do not remove the listener on port 80.

### Controlling the HTTPS port


Elastic Load Balancing supports the HTTPS/TLS protocol to enable traffic encryption for client connections to the load balancer. Connections from the load balancer to the EC2 instances use plaintext encryption. By default, the HTTPS port is turned off.

**To turn on the HTTPS port**

1. Create a new certificate using Amazon Certificate Manager (ACM) or upload a certificate and key to Amazon Identity and Access Management (IAM). For more information about requesting an ACM certificate, see [Request a Certificate](https://docs.amazonaws.cn/acm/latest/userguide/gs-acm-request.html) in the *Amazon Certificate Manager User Guide*. For more information about importing third-party certificates into ACM, see [Importing Certificates](https://docs.amazonaws.cn/acm/latest/userguide/import-certificate.html) in the *Amazon Certificate Manager User Guide*. If ACM is not [available in your region](https://docs.amazonaws.cn/general/latest/gr/acm.html), use Amazon Identity and Access Management (IAM) to upload a third-party certificate. The ACM and IAM services store the certificate and provide an Amazon Resource Name (ARN) for the SSL certificate. For more information about creating and uploading certificates to IAM, see [Working with Server Certificates](https://docs.amazonaws.cn/IAM/latest/UserGuide/ManagingServerCerts.html) in *IAM User Guide*.

1. Specify the HTTPS port by selecting a port for **HTTPS Listener Port**.  
![\[Elastic Beanstalk Elastic Load Balancing configuration - SSL\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-elb-ssl.png)

1. For **SSL Certificate ID**, enter the Amazon Resources Name (ARN) of your SSL certificate. For example, **arn:aws-cn:iam::123456789012:server-certificate/abc/certs/build** or **arn:aws-cn:acm:us-west-2:123456789012:certificate/12345678-12ab-34cd-56ef-12345678**. Use the SSL certificate that you created or uploaded in step 1.

To turn off the HTTPS port, select **OFF** for **HTTPS Listener Port**.

## Health checks


The health check definition includes a URL to be queried for instance health. By default, Elastic Beanstalk uses TCP:80 for nonlegacy containers and HTTP:80 for legacy containers. You can override the default URL to match an existing resource in your application (for example, `/myapp/default.aspx`) by entering it in the **Application Health Check URL** box. If you override the default URL, then Elastic Beanstalk uses HTTP to query the resource. To check if you are using a legacy container type, see [Why are some platform versions marked legacy?](using-features.migration.md#using-features.migration.why)

 You can control the settings for the health check using the **EC2 Instance Health Check** section of the **Load Balancing** panel.

![\[Elastic Beanstalk Elastic Load Balancing configuration - health checks\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-loadbalancer-healthcheck.png)


The health check definition includes a URL to be queried for instance health. Override the default URL to match an existing resource in your application (for example, `/myapp/index.jsp`) by entering it in the **Application Health Check URL** box. 

The following list describes the health check parameters you can set for your application. 
+ For **Health Check Interval (seconds)**, enter the number of seconds Elastic Load Balancing waits between health checks for your application's Amazon EC2 instances.
+  For **Health Check Timeout (seconds)**, specify the number of seconds Elastic Load Balancing waits for a response before it considers the instance unresponsive.
+ For **Healthy Check Count Threshold** and **Unhealthy Check Count Threshold**, specify the number of consecutive successful or unsuccessful URL probes before Elastic Load Balancing changes the instance health status. For example, specifying **5** for **Unhealthy Check Count Threshold** means that the URL must return an error message or timeout five consecutive times before Elastic Load Balancing considers the health check as failed.

## Sessions


By default, a load balancer routes each request independently to the server instance with the smallest load. By comparison, a sticky session binds a user's session to a specific server instance so that all requests coming from the user during the session are sent to the same server instance. 

 Elastic Beanstalk uses load balancer–generated HTTP cookies when sticky sessions are enabled for an application. The load balancer uses a special load balancer–generated cookie to track the application instance for each request. When the load balancer receives a request, it first checks to see if this cookie is present in the request. If it is present, the request is sent to the application instance that is specified in the cookie. If there is no cookie, the load balancer chooses an application instance based on the existing load balancing algorithm. A cookie is inserted into the response for binding subsequent requests from the same user to that application instance. The policy configuration defines a cookie expiry, which establishes the duration of validity for each cookie. 

You can use the **Sessions** section on the **Load Balancer** tab to specify whether the load balancer for your application allows session stickiness.

![\[Elastic Beanstalk Elastic Load Balancing configuration - sessions\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-loadbalancer-sessions.png)


 For more information on Elastic Load Balancing, see the [Elastic Load Balancing Developer Guide](http://docs.amazonaws.cn/ElasticLoadBalancing/latest/DeveloperGuide/). 

# Configuring Auto Scaling using the Amazon toolkit for Visual Studio
Auto Scaling

Amazon EC2 Auto Scaling is an Amazon web service that is designed to automatically launch or terminate Amazon EC2 instances based on user-defined triggers. You can set up *Auto Scaling groups* and associate *triggers* with these groups to automatically scale computing resources based on metrics such as bandwidth usage or CPU utilization. Amazon EC2 Auto Scaling works with Amazon CloudWatch to retrieve metrics for the server instances running your application.

Amazon EC2 Auto Scaling lets you take a group of Amazon EC2 instances and set various parameters to have this group automatically increase or decrease in number. Amazon EC2 Auto Scaling can add or remove Amazon EC2 instances from that group to help you seamlessly deal with traffic changes to your application. 

 Amazon EC2 Auto Scaling also monitors the health of each Amazon EC2 instance that it launches. If any instance terminates unexpectedly, Amazon EC2 Auto Scaling detects the termination and launches a replacement instance. This capability enables you to maintain a fixed, desired number of Amazon EC2 instances automatically. 

Elastic Beanstalk provisions Amazon EC2 Auto Scaling for your application. You can edit the Elastic Beanstalk environment's Amazon EC2 instance configuration with the **Auto Scaling** tab inside your application environment tab in the Amazon Toolkit for Visual Studio.

![\[Screenshot of Auto Scaling configuration panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-autoscaling.png)


The following section discusses how to configure Auto Scaling parameters for your application. 

## Launch the configuration


You can edit the launch configuration to control how your Elastic Beanstalk application provisions Amazon EC2 Auto Scaling resources.

The **Minimum Instance Count** and **Maximum Instance Count** boxes let you specify the minimum and maximum size of the Auto Scaling group that your Elastic Beanstalk application uses.

![\[Elastic Beanstalk Auto Scaling launch config configuration window\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-autoscaling-launchconfig.png)


**Note**  
To maintain a fixed number of Amazon EC2 instances, set **Minimum Instance Count** and **Maximum Instance Count** to the same value.

The **Availability Zones** box lets you specify the number of Availability Zones you want your Amazon EC2 instances to be in. It is important to set this number if you want to build fault-tolerant applications. If one Availability Zone goes down, your instances will still run in your other Availability Zones. 

**Note**  
Currently, it is not possible to specify which Availability Zone your instance will be in. 

## Triggers


A *trigger* is an Amazon EC2 Auto Scaling mechanism that you set to tell the system when you want to increase (*scale out*) or decrease (*scale in*) the number of instances. You can configure triggers to *fire* on any metric published to Amazon CloudWatch (for example, CPU utilization) and determine if the conditions you specified have been met. When the upper or lower thresholds of the conditions you have specified for the metric have been breached for the specified period of time, the trigger launches a long-running process called a *Scaling Activity*.

You can define a scaling trigger for your Elastic Beanstalk application using Amazon Toolkit for Visual Studio.

![\[Elastic Beanstalk Auto Scaling trigger\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-autoscaling-triggers.png)


Amazon EC2 Auto Scaling triggers work by monitoring a specific Amazon CloudWatch metric of a particular instance. Metrics include CPU utilization, network traffic, and disk activity. Use the **Trigger Measurement** setting to select a metric for your trigger.

The following list describes the trigger parameters you can configure using the Amazon Management Console.
+ You can specify which statistic the trigger should use. You can select **Minimum**, **Maximum**, **Sum**, or **Average** for **Trigger Statistic**.
+ For **Unit of Measurement**, specify the unit for the trigger measurement.
+ The value in the **Measurement Period** box specifies how frequently Amazon CloudWatch measures the metrics for your trigger. The **Breach Duration** is the amount of time a metric can go beyond its defined limit (as specified for the **Upper Threshold** and **Lower Threshold**) before the trigger fires.
+ For **Upper Breach Scale Increment** and **Lower Breach Scale Increment**, specify how many Amazon EC2 instances to add or remove when performing a scaling activity. 

For more information on Amazon EC2 Auto Scaling, see the *Amazon EC2 Auto Scaling* section on [Amazon Elastic Compute Cloud Documentation](http://www.amazonaws.cn/documentation/ec2/).

# Configuring notifications using Amazon toolkit for Visual Studio
Notifications

Elastic Beanstalk uses the Amazon Simple Notification Service (Amazon SNS) to notify you of important events affecting your application. To enable Amazon SNS notifications, enter your email address in the **Email Address** box. To disable these notifications, remove your email address from the box.

![\[Screenshot of notifications configuration panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-notifications.png)


# Configuring additional environment options using Amazon toolkit for Visual Studio
Advanced Configuration

Elastic Beanstalk defines a large number of configuration options that you can use to configure your environment's behavior and the resources that it contains. Configuration options are organized into namespaces like `aws:autoscaling:asg`. Each namespace defines options for an environment's Auto Scaling group. The **Advanced** panel lists the configuration option namespaces in alphabetical order that you can update after environment creation.

For a complete list of namespaces and options, including default and supported values for each, see [General options for all environments](command-options-general.md) and [.NET Core on Linux platform options](command-options-specific.md#command-options-dotnet-core-linux).

![\[Screenshot of advanced configurations options panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-linux-advanced-tab.png)


# Configuring .NET Core containers using the Amazon toolkit for Visual Studio
Containers

The **Container** panel lets you specify environment variables that you can read from your application code.

![\[Screenshot of container panel in Visual Studio Toolkit for Elastic Beanstalk\]](http://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/images/aeb-vs-container-envproperties.png)


# Monitoring application health
Monitor

This topic explains how to monitor the health of your application's website. It's important to know that your production website is available and responding to requests. Elastic Beanstalk provides features to help you monitor your application's responsiveness. It monitors statistics about your application and alerts you when thresholds are exceeded.

For information about the health monitoring provided by Elastic Beanstalk, see [Basic health reporting](using-features.healthstatus.md).

You can access operational information about your application by using either the AmazonToolkit for Visual Studio or the Amazon Management Console.

The toolkit displays your environment's status and application health in the **Status** field.

**To monitor application health**

1. In the Amazon Toolkit for Visual Studio, in **Amazon Explorer**, expand the Elastic Beanstalk node, and then expand your application node. 

1. Open the context (right-click) menu for your application environment and select **View Status**.

1. On your application environment tab, select **Monitoring**.

   The **Monitoring** panel includes a set of graphs showing resource usage for your particular application environment.
**Note**  
By default, the time range is set to the last hour. To modify this setting, in the **Time Range** list, select a different time range.

You can use the Amazon Toolkit for Visual Studio or the Amazon Management Console to view events associated with your application.

**To view application events**

1. In the Amazon Toolkit for Visual Studio, in **Amazon Explorer**, expand the Elastic Beanstalk node and your application node. 

1. Open the context (right-click) menu for your application environment and select **View Status**.

1. In your application environment tab, select **Events**.

# Migrating from .NET on Windows Server platform to the .NET Core on Linux platform on Elastic Beanstalk
Migration from Windows to Linux

You can migrate applications that run on [.NET on Windows Server](https://docs.amazonaws.cn/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.net) platforms to the .NET Core on Linux platforms. Following are some considerations when migrating from Windows to Linux platforms.

## Considerations for migrating to the .NET Core on Linux platform



|  **Area**  |  **Changes and information**  | 
| --- | --- | 
|  Application configuration  |  On Windows platforms, you use a [deployment manifest](dotnet-manifest.md) to specify the applications that run in your environment. The .NET Core on Linux platforms use a [Procfile](dotnet-linux-procfile.md) to specify the applications that run on your environment's instances. For details on bundling applications, see [Bundling applications for the .NET Core on Linux Elastic Beanstalk platform](dotnet-linux-platform-bundle-app.md).  | 
|  Proxy server  |  On Windows platforms, you use IIS as your application's proxy server. The .NET Core on Linux platforms include nginx as a reverse proxy by default. You can choose to use no proxy server and use Kestrel as your application's web server. To learn more, see [Configuring the proxy server](dotnet-linux-platform-nginx.md).  | 
|  Routing  |  On Windows platforms, you use IIS in your application code and include a [deployment manifest](dotnet-manifest.md) to configure the IIS path. For the .NET Core on Linux platform, you use [ASP .NET Core routing](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-3.1) in your application code, and update your environment's nginx configuration. To learn more, see [Configuring the proxy server](dotnet-linux-platform-nginx.md).  | 
|  Logs  |  The Linux and Windows platforms stream different logs. For details, see [How Elastic Beanstalk sets up CloudWatch Logs](AWSHowTo.cloudwatchlogs.md#AWSHowTo.cloudwatchlogs.loggroups).  | 