Easiest Way to Deploy .NET Core MVC to AWS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys Wes here in this video we're going to take a look at one of the easiest ways that you can deploy a dotnet core web application to the cloud using AWS Beanstalk and we can actually use some tooling directly from within visual studio to help us do this so let's take a look ok so here within visual studio I'm just going to select create a new project and here we're going to select an asp net core web application and then we can give it any name here just for the demo let's call it cloud MVC demo and then we'll select web application with the model-view-controller set up and so this is going to create an asp.net core MVC project and it's just going to create some directories for views and controllers and of course our models and we'll dis elect configure for HTTP for now just to keep things simple and so now you can see our project has actually been scaffold it out for us we have a simple home controller here and you can see that we have a couple of methods in here and I actually resolve index that just returns the view and the I action result privacy that just returns a view and with these MVC projects we can see that these will line up with some CS HTML files that we have in directories in our views directory that correspond to the name of a particular controller so by default this is just kind of the way that things get set up with a new MVC project although the point of this particular video is to demonstrate how we can deploy something like this to the cloud using Beanstalk so the only thing that I'll do here is we'll change this home index CS HTML page and I'm just gonna replace welcome with cloud MVC demo and then we'll get rid of this line okay now we can actually run this app locally just using the base configuration here using debug with express and this is going to spin up a little is Express server so that we can actually see our app run locally okay so we can see that our app can be spun up locally here running on localhost port six three eight nine six in my case and we can see the small change that we made just to demonstrate that we can launch our application and so I'm going to exit here and then we're going to add an AWS extension so we'll click extensions and then manage extensions and then searching online here if we just type in AWS and then we'll need to select the AWS toolkit for visual studio 2017 and 2019 I've already added this to my instance of visual studio but be sure to add it if you'd like to follow along here this will probably require you to restart visual studio but when it opens what we'll be able to do is actually from the View menu here we'll be able to select AWS explorer and so here we'll need to select a profile and you can see that I have created a profile here what we want to do now is actually create a role for this a user for this so that we can act on behalf of our visual studio application here or our user using this instance of visual studio to deploy our application and so let's head over to the AWS console to set that up okay so we're at the AWS management console and we need to visit the IIM service here and so if you can't find it very quickly then we can just search Here I am and we should be brought to the welcome to identity and access management page we're going to create a new user here and so we can select users here and I'm going to select add user and for user name I'm just going to call this one vs deploy agent and we're going to give this user programmatic access and click Next now we're going to add this user to a group let's look at how we can create that from scratch here so our group name here is let's just call this a deploy agents and we're going to give this group just a particular policy and so here we want to give them AWS elastic Beanstalk full access and so we'll create this group and the new user that we're adding now will be added to this deploy agents group and they even give us a message here but using groups is a best practice way to manage a particular users permissions by their particular job function so in this way we can give fine-grained access to users the resources that they just specifically need to perform some tasks and so next we will be able to add some tags here and if you are using AWS I would recommend adding tags to all the resources you create in general this will be really useful later on for doing things like monitoring and so in general we could add key value pairs here for the user that we're creating okay so now we're brought to a sort of summary page and we're just going to go ahead and create this user now what we need to do is to take note of the access key ID here and the secret access key note that we can also download these as a CSV file and then we will use these in Visual Studio when we actually launch our app to AWS Beanstalk so now we're going to select the Add button here and we're going to paste in our access key ID along with our secret access key note that we could also simply import this from the CSV file that we exported earlier okay and then for the profile name here I'm going to select cloud deploy okay so now with this setup let's just simply right-click on cloud NBC demo here over in our solution Explorer and we're going to select publish to AWS elastic Beanstalk so we're using our new cloud deploy account profile and here we're selecting a region of course AWS has different regions here for the purposes of this demo we'll just select us West and then we're going to create a new application environment here it would be possible for us to actually use an existing Beanstalk environment if we'd already created one okay so we're going to create our application named cloud MVC demo and we'll copy and just paste the same name for the environment here with a dash dev and so our URL will be at cloud MVC demo - dev elastic Beanstalk comm and we can actually just check availability here URL is available so we'll select next we have a number of different options in terms of our launch configuration here we'll use a 64-bit Windows Server 2016 running IAS 10 and we're going to bump the instance size down so we'll use like a t1 micro here for this of course you would want to size your instance type appropriately based on whatever you're launching for the purposes of a demo we can just launch using a simple t1 micro instance and now note that we have the option to select a load balancer however will simply be running a single instance environment so a load balancer doesn't make much sense but assuming that we would want want to run multiple instances behind a load balancer we could disel echt this and then we would select between an application and network or a classic load balancer so an application load balancer operates at the request level and I'll show the OSI diagram here that is layer 7 and this is suitable for load balancing HTTP and HTTPS traffic so we would typically use this for any type of modern web app we could use this for things like micro services or other container based processes it offers things like HTTP support so it supports HTTP termination between client and the load balancer it offers good integration with things like AWS certificate manager you can do things like route 2 lambda functions it supports WebSockets ipv6 sticky sessions health checks so in general just an extremely full featured modern load balancer that operates at the request layer we could also choose a network load balancer here which operates at a lower level in the OSI diagrams so this actually operates at level four or the connection level routing connections to targets which can still be things like ec2 instances and containers but this is ideal for balancing both TCP and UDP traffic so this is an extremely sort of low latency high-performance load balancer capable of handling bursts of millions of requests per second so in general if you're looking for ultra-high performance in a load balancer that is operating at the connection level or layer four then we'd be selecting a network load balancer otherwise if we are load balancing typical HTTP and HTTPS traffic then we'd be selecting an application load balancer here classic load balancer is just the previous version of AWS a load balanced load balancing service and is geared towards like ec2 classic and so in general we would want to select between application and network load balancer for our case we're going to just simply select a single instance environment so we won't be even worrying about load balancing for the demo and then here we'll use our AWS elastic and suck a c2 role and our service role so now we have the choice to choose different build and deployment settings here we'll use our debug any CPU which you can see is what we use to actually run our app earlier and will be running on net core 3.1 and we can specify a different app path here if you prefer and we can do things like turn on AWS X ray tracing support or health reporting well we'll leave both of these deselected for our case and I'm just going to select next and here we can get a basic review of what we're about to deploy here and we'll now click deploy so this is going to take a few minutes but in just a moment here a window will open up showing us basically what's happening as our as our environment is created and our application begins to get deployed ok so once this finishes then you can see in my case here this took about nine or ten minutes then we should see environment is healthy and in fact we have a number of different tabs and we can select here monitoring resources if we turn on AWS x-ray we could see some of that information here so it is pretty neat to have some of these tools actually available to us directly within our IDE of course all this information is also available either through programmatic access to AWS or you know even through the console so let's just select the our URL here and you can see that this will actually launch our application so our app is now running in the cloud and anyone anywhere can actually access this directly from our URL and as you can see here we can now connect to our app from any other device that is connected to the Internet ok that's really all there is to it I think AWS elastic Beanstalk is a really great service to reach for if you are just trying to deploy something relatively quickly to the cloud in general it is going to be more used if you don't really have a lot of DevOps experience or don't want more fine-grained control over the systems that you're deploying but for relatively simple projects and really just to get something deployed I think it's an excellent tool and it's also really nice to have some of the tooling built in to visual studio to allow us to deploy whatever we're working on relatively quickly thank you guys for watching
Info
Channel: Wes Doyle
Views: 25,756
Rating: undefined out of 5
Keywords:
Id: JlJ7PmNIOac
Channel Id: undefined
Length: 13min 3sec (783 seconds)
Published: Sat May 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.