Deploy web applications with ASP.NET Core and DotVVM on AWS Elastic Beanstalk
Tags: webdev, aws, dotnet, dotvvm
Published: 2020-07-23 18:12:57

Today, cloud computing is a trend in the tech world, due to its impact in generating services and computing for users and businesses. If we focus on the area of software development through ASP.NET for example, one of the direct partnerships with the cloud is being able to deploy these applications. 

In this article, we will learn how to deploy web sites in the cloud, specifically with DotVVM on ASP.NET Core 3.1 to Amazon Web Services, under a *Platform as a Service – PaaS* approach. If we remember this approach within the types of cloud services, we refer to a development and deployment environment, without worrying about managing technology infrastructure resources. 

**Activities:**

To perform language activities on AWS, we have three important parts: 

+ Part 1: Pre-AWS Configurations. 
+ Part 2: Information about the resources required by AWS for the program.
+ Part 3. Web application time with ASP.NET Core and DotVVM from Visual Studio 2019.

**Resources Required:**

To follow this article step by step, you need to have the following tools in the following accounts:

+ .NET Core SDK.
+ Visual Studio 2019.
+ The Web Development and ASP.NET workload for Visual Studio 2019.
+ The DotVVM extension for Visual Studio 2019.

###**Part 1: AWS Pre-Configurations**

Amazon Web Services, also known as AWS, is a set of Amazon cloud computing tools and services. For our deployment goal, we need to make some pre-configurations, ranging from user tuning to configuring AWS in Visual Studio 2019. In other words, these are the previous configurations we will make: 

+ 1. Get an AWS Free Tier account.
+ 2. Set up an IAM account.
+ 3. Set policies for a given user in IAM.
+ 4. Install and configure the AWS Toolkit for Visual Studio 2019.

Without more to say, let's deepen each of these previous activities and review what we need to do. 

####1. Get an AWS Free Tier Account

AWS has a free tier to test and consume services for 12 months. At the following address, we can register accordingly: [aws.amazon.com/free](aws.amazon.com/free).

This is a simple process, however, it should be noted that we have to provide the credit/debit card details in order to activate it.

####2. Set up an IAM account

All right, assuming we've already created a root account on AWS, when we sign in, we'll see the console:

![](https://dev-to-uploads.s3.amazonaws.com/i/fcsfil6kcpydckie1lsa.png)

Within the console, we'll search for the IAM service. Identity and Access Management (IAM) is a service that allows us to manage access to AWS services and resources. It also allows us to create and manage AWS users and groups, and use permissions to grant or deny access to resources. 

When we enter this service, we will go to the *Users* section in the options menu and select *Add User*. The goal is to create a user, which will be used to associate the AWS services to be used, as it is not recommended to provide our root user access privileges.

![](https://dev-to-uploads.s3.amazonaws.com/i/qty8r0unu81oy26vce8c.png)

The form to add a new user will look like this:

![](https://dev-to-uploads.s3.amazonaws.com/i/0jrg3ti9qlmh11t6wslc.png)

After we're done with creating the new IAM user, we need to download the credentials. We'll need these later to configure in Visual Studio.

![](https://dev-to-uploads.s3.amazonaws.com/i/ebzef5kzlgq3825rcywb.png)

***Note:*** It is very important to keep this CSV file in a safe place, as the login credentials are located there.

####3. Set user policies

In order to deploy our applications with ASP.NET Core and DotVVM from Visual Studio, our new IAM user needs to be able to access certain AWS services. In this case, we'll target the user in question within IAM on AWS and select the *Add inline policy* option.

![](https://dev-to-uploads.s3.amazonaws.com/i/gh3deqo8frn7e4l8iy9e.png)

Then, we need to perform this process for each of the following services:

+ Elastic Beanstalk
+ EC2
+ S3
+ CloudFormation

![](https://dev-to-uploads.s3.amazonaws.com/i/8cjcat1n427jsozsenxr.png)

After adding these services, we will name this policy and save it. In the end, we'll have something like this:

![](https://dev-to-uploads.s3.amazonaws.com/i/1qc3okmq6rrzd08mzb9b.png)

####4. Install and configure the AWS Toolkit for Visual Studio

Within the required pre-configurations of AWS, the last thing to do is to install the AWS extension for Visual Studio 2019. This tool will allow us to work with the .NET ecosystem in terms of developing, debugging, and deploying solutions in relation to Amazon Web Services.

***Download link:*** [https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017
](https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017
).

For installation, Visual Studio 2019 must be closed.

![](https://dev-to-uploads.s3.amazonaws.com/i/4fhyjl2d38gb6c37sl9n.png)

When we start Visual Studio, the AWS Setup Wizard will start and ask us to configure our credentials. In this case, we can make use of the CSV file generated in the creation of the corresponding user in IAM.

![](https://dev-to-uploads.s3.amazonaws.com/i/g73zp7s0eu5mv2x6zacc.png)

When we save our credentials, we'll be ready with *AWS Explorer*, which lets us work with the AWS services we're authorized to. This in accordance with the policies set out above.

![](https://dev-to-uploads.s3.amazonaws.com/i/lpd2rpeywxfjgx50j860.png)

All in place, we can now work with AWS from Visual Studio 2019.

###**Part 2: Information about the services required for deployment to Amazon Web Services**

As we saw in the setup process, there are several AWS services that were used to deploy our web applications with ASP.NET Core and DotVVM. Next, we will briefly see what each of them is about. 

+ **Elastic Beanstalk**

AWS Elastic Beanstalk is a cloud deployment and provisioning service that automates the application configuration process in our Amazon Web Services infrastructure. 

To use the service, developers only have to load our apps. Provisioning, load balancing, auto-scaling, and monitoring the health of applications are handled automatically.

+ **EC2**

Amazon Elastic Compute Cloud, better known as EC2, AWS's flagship service, is an Amazon solution for providing a capacity and size computing environment that can be modified. 
EC2 has several general-purpose instances that provide a combination of computing, memory, and network resources. At this address, we can learn about the types of instances AWS has and its features: [https://aws.amazon.com/ec2/instance-types/](https://aws.amazon.com/ec2/instance-types/).

+ **S3**

Amazon S3, a name that comes from Amazon Simple Storage Service, refers to an offered service that provides object storage through a web service interface. Amazon S3 uses the same scalable storage infrastructure that Amazon.com used to run its global e-commerce network. 

These objects can be different types of files than are normally found on any computer: documents, compressed zip or rar files, multimedia files, etc. All this is achieved through a bucket storage process, or "cubes" in Spanish, in which each user can place the different data and objects that they want to store. These cubes are spread across Amazon's datacenter structure so that each user can only access their personal cubes.

+ **CloudFormation**

AWS CloudFormation is a service that provides a common language for modeling and provisioning resources for an application through the AWS environment. In other words, AWS CloudFormation allows us to manage our infrastructure or a group of AWS resources in a text file or template. A collection of AWS resources is called a stack. AWS resources can be created or updated using a stack. An example stack is the resources we'll use for deploying our application with ASP.NET Core and DotVVM: Elastic Beanstalk, EC2, and EC3. 

---

Now that we've briefly known the resources that were automatically used on AWS for the corresponding deployment, we'll now move on to the practice part from Visual Studio 2019.

###**Part 3: Implementing projects with ASP.NET Core and DotVVM from Visual Studio 2019**

The project for this case with ASP.NET Core and DotVVM is based on the MVVM pattern (Model, View, Viewmodel), with each of these parts within it: 

+ **Model.** — responsible for all application data and related business logic.

+ **The view.** — representations for the end-user of the application model. The view is responsible for displaying the data to the user and allowing manipulation of application data.

+ **Model-View or View-Model.** — one or more per view; the model-view is responsible for implementing view behavior to respond to user actions and for easily exposing model data.

Taking these considerations into account, within the project in Visual Studio we will right-click on the project, and in the options section we will select *Publish to AWS Elastic Beanstalk*:

![](https://dev-to-uploads.s3.amazonaws.com/i/uiomshvdy4omfel82daa.png)

With this we'll have the AWS Elastic Beanstalk publishing wizard available, here we'll create a new application environment:

![](https://dev-to-uploads.s3.amazonaws.com/i/b9srlbeuwji1sd4x0t67.png)

Next, we'll choose a name for the app and its URL:

![](https://dev-to-uploads.s3.amazonaws.com/i/zzsa2258cc2fy2gl5bbb.png)

In this same section we can specify the environment with which we want to work:

![](https://dev-to-uploads.s3.amazonaws.com/i/70q88bulq4uqp1apm39f.png)

After checking the availability of the URL, we'll configure the hardware requirements, in other words, the EC2 instance type:

![](https://dev-to-uploads.s3.amazonaws.com/i/15dzvuz0syrvch4928nn.png)

For this particular case with DotVVM, we will work with a Linux image:

![](https://dev-to-uploads.s3.amazonaws.com/i/5zvcbrzfxifcqqvociya.png)

In the end we will see the summary of the configurations made. To continue we must click on *Deploy*:

![](https://dev-to-uploads.s3.amazonaws.com/i/83rbyy35mybax9kjwa7z.png)

From this point on, the deployment process has begun.

![](https://dev-to-uploads.s3.amazonaws.com/i/pj9vhwtap5knl63uy2la.png)

This deployment may take a few minutes, depending on the size of the application and the resources used in ASP.NET Core with DotVVM. These are the configurations that are performed internally: 

+ An Amazon EC2 VM is configured to run web applications on ASP.NET Core in the specified version. 
+ An Amazon EC2 security group is configured to allow entry on port 80. 
+ An Elastic Load Balancing to distribute requests to the instances running the application.
+ An Auto Scaling group to replace an instance if it is terminated or becomes unavailable.
+ A storage location for source code, logs, and other artifacts.
+ Two CloudWatch alarms that monitor the load on instances in our environment and fire if the load is too high or too low.
+ An AWS CloudFormation stack to launch resources in our environment and propagate configuration changes.
+ A domain name that routes to the web application in the región.elasticbeanstalk.com subdomain.

At the end of this process, almost transparent to us, we'll see our AWS-deployed application:

![](https://dev-to-uploads.s3.amazonaws.com/i/fp31bhye927t1tkmu302.png)

###**What's next?**

With this article, we learned step-by-step about deploying web applications with DotVVM on ASP.NET Core on Amazon Web Services. 

One of the great advantages of the cloud are the tools that these offer us to work with our applications, in this case, over AWS, we have been able to appreciate the concepts related to a Platform as a Service, in which we do not have to worry about internal processes or control of infrastructure, just about development as such. 

Here are some resources that might be of interest to you to continue to gain new knowledge in this area:

+ [DotVVM and ASP.NET Core: Implementing CRUD operations](https://dev.to/dotvvm/dotvvm-and-asp-net-core-implementing-crud-operations-l2e).

+ [Developing web applications with ASP.NET Core, DotVVM and MongoDB](https://dev.to/dotvvm/developing-web-applications-with-net-core-dotvvm-and-mongodb-286l).

+ [Working with web services through ASP.NET Core and DotVVM (A step by step guide)](https://dev.to/dotvvm/working-with-web-services-through-asp-net-core-and-dotvvm-a-step-by-step-guide-2le).

**Thank you:**

If you have any concerns or need help in something particular, it will be a pleasure to be able to collaborate with you.

See you on [Twitter](https://twitter.com/esDanielGomez)!! :)