AzureDevOps Deployment | CD YAML | CD Pipeline to Deploy dotnet core application on IIS

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi in this video we will see how to create a cdml pipeline to deploy a.net core application to IIs in azure devops so we will create a deployment environment in Azure devops and then create a cdml pipeline for net core web application and then deploy it on is we will use a VM hosted on Azure for this and these are some prerequisites so here I have a simple.net core web application created in.net 6.0 and the application is hosted on Azure repositories so here is the repository for the same application I have also created a Windows Server 2019 VM on Azure which we will use for deployment so on this VM let's install IIs first so in server manager under add rules and features I'll select web server IIs click on ADD features click on next select these options uninstall so now the installation of IIs is done on the VM for hosting a.net core application in IIs we also need a net core hosting bundle so we will install that too let's create a new build pipeline for this core web application so I'll go to pipeline click on new select Repository I'll rename the pipeline as core web app 0 to underscore build pipeline and here instead of vs build command I will use the.net core CLI command so delete this task under task select.net core select build command click on ADD pass the project parameter the value will be dollar solution to pick the solution name pass another parameter for configuration we will use release build configuration so it is already defined in the pipeline in this variable so I'll pass that now add another.net core task to publish the application select.net core and in the command select publish and check the published projects and click on ADD so this will publish our web application pass another parameter to use the build configuration and set the output directory to artifact staging directory to copy the published files so I'll pass configuration as build configuration and set output to build dot artifact staging directory now we also need to publish this artifact as an artifact for the pipeline so I will use another task publish pipeline artifacts in the file or directory path build dot artifact scheduling directory we can remove the published location and for artifact name we can use core web app zero to drop save this pipeline and run this so as you can see that our pipeline has successfully executed and it is produced one artifact so now we will deploy this artifact using our deployment ml pipeline before creating the ml pipeline for deployment we need to create an environment in Azure devops so this environment will be used in our yaml pipeline for deployment and this environment will connect to our server vm01 on which we will do the deployment on IIs so click on create environment provide an environment name select virtual machines click on next since our virtual machine is a Windows machine so select Windows here copy this script and go to that VM so I've opened Powershell and administrator mode here so just paste this script here and click on enter this will take some time and provide some options to configure the Azure agent so for resource tags question press enter we don't want to give any resource tags for service Sid type unrestricted agent service set yes and for NT Authority system account press enter and to start the service immediately just press enter so now the server vm01 is connected to our deployment environment so if we go back to the environment and click on resources so here you can see Server vm01 after creating the environment now let's create the deployment pipeline so click on new pipeline select Azure repost kit select the console web app to now here we will select starter pipeline I'll rename the pipeline as core web app zero to deployment pipeline delete the pulled VM image and in trigger I'll set it as none because we don't want to trigger the pipeline at every check-in now we will Define two variables here one is is web app name so I'll name it as core web app 0 to IIs and another variable for IIs website name the value will be default website delete rest of this script now we will use the artifact created by the CI pipeline in the deployment pipeline so for that we have to define the resources here for pipeline provide the value as build pipeline so what this would do is it will create a folder named build Pipeline and download our artifacts on the deployment machine we have to define the project name here so currently the project is Project one and then we have to define the source pipeline so here we have to use the pipeline name of the CI pipeline so it is core web app zero to underscore build pipeline and for branch provide the values master now we will Define the stages under that Define our first stage call it as stage underscore deploy web app provide a display name here now under a stage we can Define multiple jobs we'll Define jobs here so it is a deployment job so we will Define deployment here let's call it as job deploy web app for display name job deploy web app now we need to provide the environment name here so our environment is deployment env01 and the resource name is server vm01 so for environment we have to use the syntaxes environment dot resource name under that we have to provide a strategy strategy will be run once under the steps I'll provide checkout as none and then provide another task to download the artifact so we have to use the build pipeline name here that we have provided here provider name to display while executing the pipeline while it is download build artifacts provide the name of the artifact that we have provided in our build pipeline so it was core web app 02 drop so here we can see that we have provided the name as core web app zero to drop now we will Define a task to stop IIs first so for that we can use task from here search for is select is web app manage from the action select stop provide few additional parameters here so I'll provide the name as top is and display name would be the same under inputs we have to provide the name of the website for the defined parameter as start stop website name and we will use the variable defined here the IIs website name values variables dot is website name add another task to recycle the application pool first so again select is web app manage select IIs application pool and from action drop down select recycle and for application pool name and provide value as default app key click on ADD write the name and display name here correct the indentation now after stopping the IIs and let's add another task to deploy the web application so under tasks search for ios again now this time select web app deploy under website name we can provide the variable name here itself so we'll provide variables.is website name and for virtual application we will use another variable that we have already defined which is is web app name and for package or folder we have to provide the path to where our artifacts are copied so if we go to our build pipeline and the build pipeline has created the artifact under web app zero to drop folder and under which we have a core web app zero two so to fetch that we have to provide the path as pipeline.workspace so pipeline.workspace is a built-in variable used by deployment pipeline to point to the deployment machine and under that we have created a folder called build pipeline using this task server artifacts are getting downloaded here and under that it will create a folder called core web app zero to drop so we will provide the relative path here and under that we want to use the published folder core web app zero two so we will provide core web app 0 to here now click on ADD just type the indentations now after deployment we will just start the IIs again so I'll copy this paste it here name the task as start is under action set start website and provide the variable name here click on Save so before running I just rename this pipeline earlier so to rename this just go to pipelines select the pipeline which you want to rename and here under three dots click on rename or move click on run and it is now completed so let's go to the VM and in IIs refresh default website so here you can see that our web application has been deployed I'll browse the application so as you can see that the application is running so this is how we can deploy a web application on IIs using deployment pipeline thank you for watching the video please like the video and subscribe to the channel
Info
Channel: Jitendra Panchal
Views: 497
Rating: undefined out of 5
Keywords: #AzureDevOps, #AzureDevOpsProject, #MicrosoftAzure, #dotnetcore, #RealAzureProject, Azure CD Pipeline, CD Yaml, Azure, CD Deployment Pipeline, CD Pipeline, AzureCD
Id: hpWadvy9Yi4
Channel Id: undefined
Length: 12min 22sec (742 seconds)
Published: Tue Sep 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.