Azure DevOps release pipeline: Deploy a .NET application to IIS (CI/CD YAML tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so it looks like our job has completed successfully let's see if we can see the deployment on our server an azure devops release pipeline is essential if you want to set up continuous deployment in azure in this video we'll have a look at deploying an asp.net core web api to iis now before you do that you need to set up an azure devops organization and project and also set up a build pipeline check out our playlist at slash azure roundthecode.com for more asp.net core tutorials visit roundthecode.com subscribe to our youtube channel at youtube.com roundthecode and follow us on linkedin aroundthecode.comlink10 check out our.net 6 course on dependency injection and mass for software developers visit roundthecode.com courses this is the asp.net core web api that we're going to be deploying to iis it's the same web api that we used in our build pipeline if we give it a run we can see it's a very simple api with one endpoint the goal here is to deploy this application to this folder here if we go into iis and go into basic settings we've already set up a site name and a physical path we've also set up a site binding render into azure test project if we go to azure test project we can see we're getting a response of this is a test if we go into our index.html file we can see that the text in there is this is the test so we've got it successfully set up in iis now it's time to create our release pipeline we're in our azure devops project and the first thing we want to do is to create an environment by creating an environment it means that we can link our deployment server to our azure devops project so we go into environments and we create an environment we're going to name it windows 11 server and we're going to select the resource as virtual machines we've got a provider of generic provider and we've got a choice of operating system we can either select windows or linux now we need to run a registration script onto our deployment server and to do that we click the copy button there and we paste that script into a powershell window with administration mode let's go ahead and run that so it's going to give us a few options we can pretty much press enter for each of them and use the default option and there we go our service has been set up if we go into our services we can see that our azure pipelines agent is running for us this has been set up to run from this folder going back into our azure devops project we can see that our resource has been set up shortly we're going to be creating our release pipeline but before that i want to rename the build pipeline so i go in there i go to edit i click on the three dots up here and go to triggers go to the yaml tab and i'm going to rename it to build pipeline go ahead and save that and if we go back into our build pipelines we can see that it's been successfully renamed time to create our release pipeline we go up here and create a new pipeline we're going to select where our code is it's in a github repo so i'm going to select github we're going to select the replay that we want to select we're going to select azure test project and to configure your pipeline we're going to go with the basic and go for starter pipeline we're going to go ahead and delete all the code there but we're going to keep the comments in because we need something in there to actually save the file so this is going to save it to our branch now before we get going i want to go ahead and change the name of this so once again i go to the three dots and go to triggers go to the yaml tab and we're going to name it release pipeline and save it go back into our pipelines we can see that our pipeline has been successfully renamed let's go back into our release pipeline and start to code it our first task is to set the trigger normally what you can do is when you have a commit to a branch you can trigger it to fire off one of the pipelines that would be good for a build pipeline but for a release pipeline we want to wait until the build pipeline has finished so what we do is we need to turn that off so we use the trigger key and we select none next we're going to set a variable now with our rs website we've named it as your test project so we're going to name that as a variable to do that we use the variables key and we're going to call it iis website name we're going to put the value as azure test project next we need to link the build pipeline to our release pipeline to do that what we do is we call the resources key and we call the pipelines key within that we need to set the pipeline and this is an alias of our build pipeline it can be anything we're going to call it build pipeline but you can call this what you want next we need to set the project within it you can see up in the top left that the project name is azure test project so we're going to go ahead and add that in as our project now for the source we need to set our build pipeline name remember we renamed it as build pipeline so we need to make sure that it's correct in there and it's case sensitive as well finally we need to state what branch we want to use we're going to use our main branch now we need to go ahead and set up some stages so we call the stages key and we set the stage id as deploy website we're going to give it a friendly name as well of deploy website and set up a pool as well with a virtual image of windows latest within the stage we need to set up some jobs so we call the jobs key and the deployment is going to act as the id on here so we're going to call it deploy website once again give it a friendly name deploy website and we need to link our environment that we set up earlier so to do that we call the environment key i'm going to state windows 11 server dot dave if we go back into our environment we can see that the name of the environment is windows 11 server and it's on a resource called dave so that's how we're getting our environment name then after that we just have to state a strategy that we're going to run it once and we're going to be deploying now we need to go ahead and set up some steps within our job so we want to state that we're not checking out the code from github for this task so we set checkout as none you need to set we need to download the artifacts to do that we need to state the build pipeline alias so this is the alias that we set up here we want to be linking to that particular pipeline when we're downloading it so we call it for the download key we're going to give it a name of download build artifacts and a display name of download build artifacts as well but with spaces now for artifact we need to set this as azure test project if we go back into our pipelines and go to our build pipeline and we have a look at the last run job we can see that an artifact was produced and the name of it is agile test project that's how we get our artifact name the next task that we want to do is we want to stop our is website on our deployment server we can do a search up here and we can go for ios web app manage so for this we want to select stop and for the website name we're going to go ahead and select a variable so we're going to put variables.is website name if we go back up here we can see that our is website name has been set as our variable so that's how it's representing the website name there we're also going to go ahead and give it an id stop iis and the display name of stop is website afterwards we want to go ahead and deploy the website to iis so once again we do a search for the task and we're going to go to ios web app deploy the website name once again we're going to use our variables now for the package and folder what we need to do is we need to select a pipeline workspace variable within there and then we're going to select the alias name for our build pipeline the name of our artifact which is azure test project and the path where our deployment files are going to be sitting in our artifact file which is around the code azure test project we also want to go ahead and take the app offline a couple of things we want to do is we just want to go ahead and add a name and a display name as well i'm going to call it deploy iis and change the display name as well now we want to go ahead and start the application and to do that we're going to do a search for is once again go to our is web app manage again i'm going to select start as the action we're going to select the variable's name again and we're going to add that job in and once again we're going to select a name and a display name i'm going to call it start iis start iis website before we run our release pipeline we need to make sure that we save it to our github repo by default it will append a hyphen 1 to the file name that is because when we created our build pipeline it would have created it as azure hyphen pipelines.yaml so for this it's going to be named as azure hyphen pipelines python1.js let's go ahead and run our release pipeline to see if it's going to run for us so it looks like our job has completed successfully let's see if we can see the deployment on our server we can see that our files have been deployed and if we run our endpoint from our azure test project we can see that it's rendering so we've successfully released a project to ias through azure devops now i just wanted to talk you through how we get the package path the pipeline workspace is where the folder is for where the azure agent is running it's this folder path here this is the folder path where it will download the artifacts prior to deployment for the build pipeline that just takes the alias from the resources up here so it's the pipeline that we're looking for now the rest of the path the azure test project and around the code.azure test project that is taken from the artifacts file if we go into our build pipeline and we go into our latest job and look at the artifacts we've got the azure test project here and that's deployed it into our folder called roundthecode.azuretestproject we can see all our deployment files here so that's how it gets the full package name now a top tip if you're struggling to work out what the pipeline.workspace variable is outputting what we can do here is we can go ahead and copy that i'm going to set a new task up here but rather than using the task key we're going to use the script key we're going to call the echo command and paste that in we're now going to go ahead and run that when running our release pipeline it's created an additional task for us called cmd line what that's done there on 914 is it's outputted the full path this is the location where the azure pipelines agent has downloaded the artifacts from our build pipeline so that completes our azure devops series in the series we learned how to set up an organization and project set up a build pipeline and a release pipeline from there we can use continuous integration and continuous deployment for any dotnet website let us know in the youtube comments how you're using azure devops thanks very much for watching and hit a like on the video
Info
Channel: Round The Code
Views: 34,212
Rating: undefined out of 5
Keywords: release pipeline azure, azure ci cd pipeline, azure release pipeline tutorial, azure devops iis web app deploy, Azure DevOps CI/CD Pipeline tutorial, azure devops iis, azure devops iis deployment, azure devops release iis website, azure devops environment, azure devops environments yaml, azure devops resources, azure devops artifacts download, azure devops release, azure devops, create release pipeline in azure devops, how to create release pipeline in azure devops
Id: L_bou0a8mH8
Channel Id: undefined
Length: 14min 33sec (873 seconds)
Published: Fri Jul 22 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.