Deploying .NET Apps to Azure

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you know it's always great to finish building a project and run it on your laptop but eventually you have to get it out there you've got to get it in the cloud on the web and publishing it is an important step I've got Andrew hall with me and you're gonna share I'm gonna show how to deploy an application from visual studio to be live in Azure in less than 5 minutes nice welcome to another episode of on net my name is jeremy likeness and I'm here with Andrew Hall who's going to share with us how we can deploy from visual studio Thatcher Andrew tell us a little bit about yourself yes so as you said my name is Andrew hall I'm one of the program manager leads in Visual Studio my team is responsible for the Cornette to lean things like gives you intellisense the compiler the web tools and also the azure published tools for publishing to all the places in Azure that we support directly from Visual Studio great so that's exactly what we're talking about today I'm a developer I've written some awesome code it's running on my laptop eventually though I have to get it out there for other people to see it so we are going to dive into deploying apps to Azure from Visual Studio correct all right well show us what you got ok yeah so let's go to my Visual Studio instance so what I have here is an asp.net framework application that's set up to do individual user authentication with a sequel server so ok asp.net application that requires a sequel server to function correctly so everything's working great on my local machine as you said I want to test it up in Azure sure so the easiest way to do that for my own purposes is to right-click say publish and this will bring up the published target wizard so for an asp.net application have a couple options in Azure I can go to as your app service this is where we recommend that people start if you don't have an opinionated place for where you want to go or I can browse for an existing as your virtual machine so the nice thing about as your app services we actually let you create an instance if you don't have an existing one already directly from Visual Studio you don't have to leave visual studio at all right for an azure virtual machine if you have the machine set up and this link here says how to enable publish and reversing will take you to a tutorial that tells you how to create the virtual machine and get it in a state that visual studio can publish to we don't offer the ability to directly create that virtual machine from visual studio okay so we're looking at basically the difference between a platform as-a-service option right app service is going to have everything set up for me to run my application versus a virtual machine that requires plumbing the OS the configurations that's correct and one of the reasons we offer ya app service directly from visual studios as you mentioned platform-as-a-service it's super quick as you'll see here because we're gonna start from scratch we will basically be done in less than two minutes okay we're gonna hold you to that virtual machine significantly more than that and so we think you're just gonna have a better experience if you go through the portal pick all the options that you want get all those knobs right and then there's go can browse for it once it exists okay great alright so let's go ahead for app surface two options I'm ready in the mode that says create profile what this would let me do is let visual studio create everything in Azure but it's actually not gonna copy my bits up yet okay and that's what I want in this case the other option would be to publish immediately okay creep profile is great because I mentioned that I have sequel server and I'm gonna tweak a couple knobs to get my enemy framework migrations working correctly before I try to run the application for the first time so let's go ahead and click create profile is this gonna pop up our create app service dialog in visual studio of course it has decided to log me out because that's the way that these things work whenever you get ready to go record a video it worked earlier today so should just take a couple seconds here to log me back in so I'll talk about right now though while we're on the page you can see that I wasn't logged in with an account that had an as your subscription associated because it had expired in time you know so I was at that page that basically told me you don't have an account either login or create a account had a link to go create a free Azure account right so I can actually if I don't have an edger count I can create a free account and play with these bits do what you're about the to show us exactly so that link that was there will take you to the dotnet as your account page it's worth mentioning just for a second that two things one you get if you don't have a visual studio subscription and it gets $200 worth of credits that are good for a year and but if you have a visual studio subscriptions of professional enterprise something along those lines you actually have free azure credits that were new every month available to you if you want to play with any of them okay so if your company or personally have actually gotten a Visual Studio subscription you have depends on the subscription level but anywhere from 50 to 150 dollars a month and free azure subscribes to play with so take advantage of those so take advantage of those and so what I'm about to show at service with a standard application app service plan if you run it for an entire month that's 44 dollars a month okay so there's a lot of up adjure you can play with with a fifty dollar credit sure sounds good so what we're in right now is we're in the create app service dialog so it's gonna ask me what I want my application name to be this is gonna be the URL that's going to actually appear for me in Azure more numbers is better right I have more numbers is better yeah so to make sure that this has to be unique across all of a sure right so I bet if I do my web application that's going to tell me that it's not available so one two three is available so what we do when you come into this dialog to make sure that you can be successful if you look really close up ad it's a time date stamp okay so we just default to the time date stamp so you're not in an error condition to start off but obviously it becomes easy to change if you want to change it to whatever you want subscription this is my Visual Studio Enterprise subscription so I'm gonna use my as your credits that I already have available to me what resource group do I want to put it in let's go ahead and just create a new one we'll call this on dotnet perfect hosting plan so as your hosting plans this is basically the amount of resources I want dedicated to my website okay so what we default you to is a standard plan which means I get one cool and 175 gigabytes or sigh 1.75 gigabytes of RAM it's not 175 gigabyte right one point said my desk 175 would be crazy correct by the way and so then I can pick the region that I want it to be in I'm gonna go ahead to West us two and I'll explain why I'm gonna do that here in a second okay so I click OK you can see that application insights this is our application performance monitoring system that's going to record - Emma tree so to get crashes performance information about my request automatically on my behalf if I choose a region that has application insights in that same region it's gonna default if the beings on and so then once I publish it's just there for the purposes of our show today I'm actually gonna say to show how to do it if I don't want application insights just because this is a real quick test thing I don't need the APM so I'm gonna go ahead and say none but everything would have been created and configured correctly for me but the last thing I do need and we talked about this I need a sequel server database right and if I want a sequel server database in Azure I click this create a sequel database button here and so I need a new sequel server and so the reason I picked West us two is notice that I'm using a visual studio Enterprise subscription and for capacity reasons Asher has limited the regions that can create sequel server databases okay and so I can see this message here tells me that this location does not support my subscription type choose a different one so I'm gonna go ahead to West us - because I know that one does let me create sequel servers under visual studio enterprise subscription okay um and then let's pick a username and password so this is my username of Microsoft and I have to do a secure password I'm not gonna say that is out loud but perfect ok so you've gone through the dialog and what it's showing you here is a summary in the lower right of your display of what it's gonna create in Azure and I see it's building up a server it's creating a database on that server there's a hosting plan which is where you specify the size of the machine then there's the actual app service that hosts the web app yep that's correct let's go ahead and click create and I think you said you were going to hold two minutes so set your watch okay we got it run in yeah but I think the important thing to point out now that now that we have that off and running is to point out that we didn't do anything we didn't create your resources in Azure no none of your credits or no cost was being built up until you actually click the Create button so I'll go get everything configured set up like I wanted and then once I click the Create button that's when this deploying step one is actually now where what it's doing its going in creating those resources in Azure for me so basically I'm a little bit old school I was working on applications back in the day when we'd stand up a physical server located somewhere install sequel server which could take quite a bit of time sort through licensing cores everything else deploy the database app so all those manual steps that we used to do on physical hardware are happening automatically for us in the cloud this is one of the reasons why we like using the cloud exactly yeah that's correct so yeah it's exactly it's creating a what would be the equivalent of an i is site for you on your Windows server you don't have to pick up the phone and call the ops person and you know send them chocolates or whatever to get that done you've created the database that you're now an administrator of again no working with the ops team or trying to deal with licensing or get anything installed on your machine locally and so yeah it should be about two minutes you'll let me know how we do on that but pretty cool that you can do all of that from visual studio and even if it took 10 minutes and I wanted to say too when we created the plan you set a very specific plan and said this number of cores in this much memory is that something that if later after we deploy is easy to change if I want to add more memory or change the course for example absolutely so I just have to log into the azure portal and I'll show you a quick shortcut to get to the resource in the azure portal once we finished a plane through a tool window that we have a visual studio called cloud Explorer we can take you directly to that resource in Azure but yeah under settings if you want to adjust the size of it you have the ability to upgrade or downgrade the size of that resource you can increase the number of instances so if you need to stay all it's really popular you can increase it to up to ten instances so you have up to ten different machines hosting your application so we have the ability to scale out with more instances and up with a larger size machine and we're just over two minutes I just failed yes just missed it by by a few seconds I think but here we are so it says it's ready to go yeah so I mentioned that what we were gonna do as I was going to show you how to apply EF migrations because what this website does is it requires a database and so write EF migrations that have to run to work correctly it's the way that I get in get to those I click configure and this is going to bring me to all of my advanced settings that I can do with this particular application so once I click to this tab I can so what the spinner right here is telling me that it's actually doing a build of my application and trying to detect if there's any EF migrations that okay are running as part of the site so it's automatically detected that you have entity framework and you're using sequel and it's working with that to set up the migrations well it's detecting if I have any any EF migrations right right now so once that spinner finishes which because it's doing a full build in the background could take all this this is where I share the secret right when you're running live demos if you've moved the mouse clockwise it should help speed things up I don't know if you've ever tried that I did not know that yeah you should try it let's see what happens I like it okay maybe not for this instance but in general that's something to try out and use so what that'll do is that'll go ahead and detect the connection string so I'll expect my default connection that we populated up there to appear here oh there we go so it's actually detected the connection string of the database that I'm using here okay for those who would like to get it from home so update database so I want to go ahead and update that database as part of publish okay is what that checkbox does and then I click Save and now I'm going to click the publish button and what this is going to do is this is going to deploy my application directly up into the cloud it's going to run those EF and any framework my creations so what it's doing is kicking off a build right now it's running my application up in Azure publishes succeeded okay and so now I can see my Microsoft edge down here and so what it's doing is its popping my website and I'm gonna expect that website to open for me in the cloud and I should see an asp.net up web application running for me and a sure so we did feels like three steps and third one was easiest one the first step was you built the profile and that prep Thatcher and gave you the sort of the resource targets that you're gonna deploy to the second one was it built and took the result of that build and published it and then lastly we navigated to the site to verify it we didn't actually the third step was automatic so I'd actually automatically popped my browser for me just cuz I had at the background it was blinking bright it didn't come up with my face but Visual Studio actually opened the browser to the right tab okay and so that's whatever the default browser on my machine would be and so I have my application running and you were asking about how to manage the application if I wanted to change anything about it sure so if I click this managing cloud Explorer button here what it's going to do is it's going to open order this recently use tab it'll give me my site and so if I right-click on it or it's available down here and the actions pane I have the option to open the portal which would let me go manage things about it open in the browser which would if I don't remember the URL which I could click here but if I'm here I could browser I can even attach a debugger so if I needed a remote debug my application because it wasn't working correctly I can do that from Visual Studio as well nice all just fully integrated right out of the box always fully integrated so I don't remember to get there just click the manage and cloud Explorer and I'm there nice I like it so last thing I think we should talk about so I talked about asp.net dotnet framework application right there's some more options that potentially become available to me I depending on the deployment method that I want ok so if I if you have you heard of docker containers Jeremy I have heard of docker containers big big fan I suspected you might be familiar with them so if I click Add and I say docker support which should be somewhere on here Oh container orchestration support so say docker compose so now what this is going to do is this going to add the stuff to my application to build it as a docker file and for anyone not familiar with docker basically it runs off a set of instructions that tells us how to build the application and how to build a container to run the application and what it's doing is it was complaining I don't have docker actually running on my machine so that's what I got that air doctor doctor so that was an error message from visitors to you but I don't need it for the purposes of what I'm gonna show you ok the container actually won't be built which is why I got that error I would just need to start docker which isn't currently running ok but if I click new profile now I can see that container registry appears as well so explain a little bit about what a container registry is yeah so I think you are sorry I think I might have actually interrupted you as you're explaining what docker is but docker packages your application and all of its dependencies into a single unit which is a called a docker image file right and so then a container registry is an intermediate store for hosting those image files that I can then pull from production right and I like to tell people we're used to the traditional life cycle where we check in source code and we track source code and then we build and deploy with docker we can build that image and then we can track that image just like we would source code and the image is what we move in deploy after that correct and one of the really cool things that plays into there is when you update so publish an update or in production environment you pull an update so everything goes to the distri everything's a diff from your previous image okay so instead of let's say this image was I'll make it up but let's say it was 1.2 gigabytes so the first time I published and the first time I deploy it to productions would ask to copy it now for the container registry it's once you point two gigabytes each way next time if I change one DLL that changes the image by 1.2 megabytes I only publish and pull one point you may it's just a little bit of a layer correct that that's sandwiched on top because everything's versioned we only have to update that extra layer right okay so that's the one thing that we get again dotnet framework so this is all the targets that are now available to me from a dotnet framework project okay if I were to do a create a dotnet core project which I have a couple of them hanging around so let's just open a recent one so I think what application two should be a asp.net core project that'll open here and a couple seconds I'll have a couple additional targets you can see that this is a dominant chord - OH project should upgrade it two to one now but two ones all right I'll be fully available but turns out those I was ten actually testing this for purposes so yeah that's why it's there no need to change things at the last minute but let me go ahead and just delete this profile look so I already had a published profile in here okay but once I have poached a file I also have app service linux available to me and so if i prefer from organizational purposes or personal preference to run my application on linux rather than Windows as your app service that we looked at a little bit ago as a Windows environment okay I also have a linux environment available to me and because I have docker eyes this project as well you can see that there's a docker file over here in solution Explorer I have app service for containers available to me which I've service for containers is the idea that I create a Linux environment and app service but I'm publishing my own container rather than so you know the app service the traditional model is I give it my code it decides how to configure the hosting environment and all the dependencies in this model as your provisions some computing resources but it's gonna actually pull whatever image I tell it to pull so you have bring your own container basic bring your own container is exactly what it is and the other thing I would say we've got a lot of different published targets and this is a great way to get started as a developer I'll right-click I'll publish I'll make sure it's working in the cloud all of these can be used as templates to build a full DevOps pipeline right and have an automated workflow that's correct so you'll notice here at the bottom of the publish page we offer the ability to set up continuous delivery directly from Visual Studio which will automatically configure a continuous delivery pipeline if you wanted from Visual Studio using visual studio team services as your build server great doing that now this particular one is going to not be happy with me because it's not checked into source control so I'm gonna go ahead and share and bail out of that it's one of the prerequisites I'm not going to satisfy the prerequisites but yeah so absolutely can be used as a template for getting full continuous delivery pipeline setup okay well we've covered a lot of ground today what I like is that you didn't just show me a simple web app we've had an app with a sequel back-end with security and and all the pieces we'd have in a real world app if you will but it is as simple as going into visual studio we've seen a bunch of different options to publish it if we want to go the the virtual machine route we can but there's these really nice go straight to a container go straight to an app service options absolutely I'll give one more plug which goes back to your full devops pipeline we would as a recommendation on the team say that we think that you should use the right click publish to deployment generally for your own developer testing purposes sure if you're going to send something into production it's generally a best practice to set up a continuous delivery pipeline because that's going to archive all the build information all your symbols all your source you can control who actually has access to touch the production environment okay and it sounds like it's a good topic for us to cover in the future is that whole continuous delivery pipeline and I happen to know a few DevOps people so I think we can make that happen sounds great awesome well thank so much for coming on the show and sharing with us this new option thanks Jeremy [Music] [Applause] [Music]
Info
Channel: Microsoft Developer
Views: 27,595
Rating: undefined out of 5
Keywords: azure, .NET, mobile apps, how to deploy, mobile dev, development, computer programming, how to, educational, tech tips, technology, microsoft, channel9, channel 9
Id: 6VK370-Yk3A
Channel Id: undefined
Length: 22min 9sec (1329 seconds)
Published: Mon Oct 15 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.