Deploy Web Applications With ASP.NET Core And DotVVM On AWS Elastic Beanstalk

Introduction 

 
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:
  1. Pre-AWS Configurations.
  2. Information about the resources required by AWS for the program.
  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:
  • .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.
 
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.
 
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.
 
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.
 
 
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.
 
 
The form to add a new user will look like this.
 
 
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.
 
 
Note
It is very important to keep this CSV file in a safe place, as the login credentials are located there.
 
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.
 
 
Then, we need to perform this process for each of the following services,
  1. Elastic Beanstalk
  2. EC2
  3. S3
  4. CloudFormation
 
After adding these services, we will name this policy and save it. In the end, we'll have something like this,
 
 
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.
 
For installation, Visual Studio 2019 must be closed.
 
 
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.
 
 
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.
 
 
All in place, we can now work with AWS from Visual Studio 2019.
 

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.
 
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.
 

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,
 
 
With this we'll have the AWS Elastic Beanstalk publishing wizard available, here we'll create a new application environment,
 
 
Next, we'll choose a name for the app and its URL,
 
 
In this same section, we can specify the environment with which we want to work,
 
 
After checking the availability of the URL, we'll configure the hardware requirements, in other words, the EC2 instance type
 
 
For this particular case with DotVVM, we will work with a Linux image
 
 
In the end we will see the summary of the configurations made. To continue we must click on Deploy,
 
 
From this point on, the deployment process has started.
 
 
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:
  1. An Amazon EC2 VM is configured to run web applications on ASP.NET Core in the specified version.
  2. An Amazon EC2 security group is configured to allow entry on port 80.
  3. An Elastic Load Balancing to distribute requests to the instances running the application.
  4. An Auto Scaling group to replace an instance if it is terminated or becomes unavailable.
  5. A storage location for source code, logs, and other artifacts.
  6. Two CloudWatch alarms that monitor the load on instances in our environment and fire if the load is too high or too low.
  7. An AWS CloudFormation stack to launch resources in our environment and propagate configuration changes.
  8. 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,
 
 
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:
  1. DotVVM and ASP.NET Core: Implementing CRUD operations.
  2. Developing web applications with ASP.NET Core, DotVVM and MongoDB.
  3. Working with web services through ASP.NET Core and DotVVM (A step by step guide).
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!! :)


Similar Articles