Day-5/16 Azure DevOps Release Pipelines | Blue Green Deployment | Azure DevOps Zero to Hero series

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone welcome back to my channel my name is p and this is video number five in the series Azure devops 0 to hero in this video we'll be looking mostly into Azure devops release Pipeline and this is a continuation to the previous video we'll be using the same project of YouTube clone in this demo as well and let's have a look at the agenda all right so I am in my GitHub repository Azure devop 02 you should already have the link if not it's there in the comment section and in the description as well so as I've mentioned this is a continuation to the previous video and we'll be using the same project of YouTube clone and in this we'll be doing the automated deployment with multi-stage release pipeline so we'll create the separate stage for Dev environment and for prod we will look into the continuous deployment triggers and deployment slots to enable blue green deployment this is a deployment strategy we'll talk a little about it and then we'll see how it works actually in azure devop we'll also look into deployment Gates such as query work item and approval before the prod deployment and finally we'll create a pull request to test the entire cicd process from scratch using build and release Pipeline and with that being said let's start the demo so I am in my Azure devops project uh you should have the link and this is the project that we created for the previous video and we'll continue on that so I'll go to the pipeline and release pipeline L from here now there is no pipeline that has been created yet so I'll click over here which says new pipeline to create a new pipeline so this is a little different than the build pipeline that we saw because it does not have the yaml option there is only the GUI based pipeline that we can configure so that is the reason most of the organization prefer doing the cicd in just with the build Pipeline and they don't use this one because it don't give you the flexibility of managing pipeline as a code U but some of them use it because it comes with a few additional features such as quality Gates uh approval and all those things and you don't have to explicitly write the logic for it because it comes with release pipeline out of the box um so it totally depends on your requirements but as part of this course we'll be looking into each and everything so that you get to know how it works the same way when you click on new pipeline this screen will appear which will ask you to either select a template or start with an empty job we can start with a template which is azure app service deployment click over here or you can search any other template if you are using a different text tag so let's call this stage uh a different name instead of the default one we'll call it Dev deployment close it and over here you see this uh particular GUI uh the first one is artifact and then we have stages so let's look into the artifact first artifacts is nothing but the builds that it requires from either from the Upstream system or from the artifact repository artifact repository we'll be looking into the later video but over here we'll be using the build artifact that was generated from the build pipeline itself so to do that click over here add an artif effect and select the source type as aure build because this is our source where our build AR effect resides project is same YouTube clone and then click on the drop down and select YouTube clone okay and keep everything as default because we'll be picking the default version if you need to deploy any particular version that you can select that as well like go over here specific version and just mention the version details but for now let's just pick the latest version and hit add so now this will add the artifact step over here and if you see see there is a little icon over here uh with the thunder sign and this represent continuous deployment trigger so if you click on that you can now set the CD trigger so whenever there is a new build available it should trigger the CD pipeline right so you can enable it but just like doing this and you can specify the branch on which uh it is available so if you select this and select the option the builds pipeline default branch you can add multiple Branch as well but this will just work fine for us then there is a pull request trigger it says enabling this will create a release every time a selected artifact is available as part of a pull request workflow right so for now just let's just uh keep it over here whenever a new build is created just close it so now our first step is completed there is an option to set a schedule as well like if you want to trigger The Continuous deployment at a particular time at a particular day you can select this and you can enable this option and select the time as per your preference but for now we'll be just using the first trigger which is continuous deployment so over here as well if you see in the stage it has some pre-employment conditions and some post- deployment conditions so let's look into the predeployment conditions first so it has a trigger so trigger will be auto trigger like after the release or it could be manual like you just have to click deploy every time you want to uh trigger this stage so let's just use this one after trigger and then artifact filter if you add this if you enable this you can add the filter over here like which branch you want to run on like main branch and that should be good this is what we need okay or you can set the schedule you can set the pull request deployment and pre-deployment approval we'll add that into the prod deployment but not for the test deployment right I'll show you how it works and then we also have something called as quality Gates so if you enable this feature it will show you few options like the delay between the evaluation so before that let's set a deployment gate over here click on add and there are few options that you can check so let's say query work item okay so let's select the query go to Shared query I don't have any queries created um okay so I'll go to uh this project YouTube clone okay and go to boards I don't have any work item created for this board and there are no queries at all so I'll just quickly create a work item let's create a task and give it a name quality gate check right so let's keep it in to-do State save and maybe change it to doing save now let's go to queries and create a new query um let's add the query filter priority and priority equal to 1 okay and let's remove the other filters so this should be good and then save queries and make sure like let's give it a name P1 tasks let's call it that and make sure you save it in shared query so that it has access to it click okay okay and let's see if it uh if it is showing any results if you go to chart or result there is nothing because we don't have any P1 work item so let's go back to work item and go to this task and change the priority from P2 it's over here the default priority is P2 so change it to P1 okay hit save and now let's go back to queries again and shared queries this one and now let's see now it is showing one item in result and in chart it is not showing anything because we have to create the chart for it so if we do that and let's say select group by work item type and save chart now it is showing one item okay so now we have the result now let's go back to our release Pipeline and select the query again okay maybe I'll just close it and open it again so that it will refresh click over here again okay so now let's create the deployment Gates again uh query work item go down display name query work item and select the query expand this and uh this query is now available over here this is the one that we have created in this particular project it says upper threshold that means the maximum number of matching work items from the query it could take into account so let's keep it two for now go to advance lower threshold 0 is fine and that should be good then deployment CU settings maximum number of parallel deployment that means if we have multi-stages and if it could run in parallel so let's keep it one for now and the subsequent releases should be deploy all in sequence or deploy latest and cancel the other you can select as per your preference right so we have added a deployment gate over here right which is query work item there are other options from which you can select for example you want to trigger any rest API or there are other options that we saw you want to invoke a rest API or invoke Azure function check Azure policy compliance or query Azure monitor alerts so you can use any of those as well right earlier the query was not visible over here because I didn't have any matching bugs available that could match the query and the query was not created okay so that's it you can click close now let's add uh job and task to it click on that now this is similar to the classic UI of build pipeline let's select Azure subscription from the drop down and this is again the service connection that we are talking about then type is web app on Linux and app service name this is the app service that we created okay this one now let's leave the startup command as blank because it will take care of of it so this is the deployment and then run on agent let's use the same agent asure pipeline like this is the default agent and ubun to latest the one that we used for our build pipeline all right and yeah it will download the artifact by default from the previous stage and go to this section now now this section has similar details like connection type Azure resource manager webx on Linux so this inherited from the previous stage now there is a option over here which says deploy to slots or app service environment if you remember while creating the build pipeline I told you that I'm going to explain it to you when we reach there so now is the time I'm I'm explaining it to you deployer to slots that means Azure app service provide a functionality of slot so it create an identical environment of your actual environment and you can make your changes in that environment so if you click on that right it will ask you where is your uh staging slot or Dev slot uh available so if you select on that select the resource Group and Slot currently I did not created any slot let's go to our Azure portal and create the slot first so here I am in my Azure portal and on the left side you will see an option under deployment it says deployment slots click on that okay now it says there is only one deployment slot which is the default one and which is running your production workload right so let's click over here add slot and I will add it I'll give it a name staging now if you deploy the website to the staging slot it will be accessible over this URL now you see it has appended hyph staging along with the DNS and our main website will be available on Tech tutorials with p. asure website. net so there is a separate domain created for you for just your staging environment hosting right let's clone the settings from the main app okay and hit add now if you see over here it says your 100% traffic is going to Tech tutorials with P this domain and your 0% traffic is going to Tech tutorials with P Hyun staging another domain this domain we haven't deployed anything on it yet and on the production one we already have something running and let's go back to our Pipeline and now if you refresh it you should see a staging slot over here right so now our app will be deployed on the staging slot and package or folder let's select the package folder okay so drop click okay runtime stack will select the static one one okay and that's it hit save okay let's give it a name YT clone CD save go to all pipelines YT Clon CD and hit erit now we have our artifact stage created we have the test deployment created now we'll also create one stage for production deployment so you can click on ADD over here to create a stage or what you can do is you can clone the existing stage and make your changes so let's do the cloning over here click clone okay it says it created a new stage click on that now let's rename it to prod deployment cancel now go to predeployment conditions and in this one we'll add so predeployment is test deployment is the predeployment that means before triggering the prod deployment the test deployment should have been completed already right and if you go down and if you see predeployment approvals over here so you click on that and let's add myself as the approver because this is a prod deployment we want some sort of a manual approval before it actually triggers the deployment right and this is the timeout if if someone does not approve it in 30 days it will fail it and there is an option that a user requesting a release or deployment should not approve it that means if I am requesting it I should not be the one to approve it but but we are just doing the demo test so I'll just leave it blank which is the default option and that's it uh cck cancel and then go to job um that's these details will be same the only thing that we need to make here is change the staging slot to production slot right so press everything I'll just verify it everything it looks same click over here now you will see there is nothing called as production slot because this is the live environment so to select that you just have to uncheck this box okay now it will deploy to your default production slot so this is also good now hit save go back to the pipeline okay so our pipeline looks good now let's open the build pipeline in a new tab and this was the pipeline and hit edit if you remember in the previous video we added the deployment stage over here only in the build Pipeline and we don't want it because we want deployment to be triggered from the release pipeline now let's remove the entire deployment stage it has two tasks one is download artifacts other one is the deployment and both will be taken care of release pipeline but we have configured so I'll just delete it and now what it will do is it will just build the artifact from the main br branch and it will publish the artifact in the drop container it's save now if I save it because the containers integration is already enabled it should trigger the pipeline let's see okay save let's go to pipelines and it's already queued the pipeline to be triggered so let's see this now build is running okay so this job has been completed now there are no errors and one artifact also prod produced now let's see if it triggered the release pipeline go to releases and I see One release already over here so click on that okay so now it says uh it was able to pull the artifact now it is processing the gates click on logs okay it is querying the work item and if you see it says query work item failed because we already have a blocking item as per the query if there is a work item with the status as P1 and if it is not in the done State the deployment should not trigger so which is what has happened over here and it will evaluate the gate again in 4 minutes because the evaluation time between the gates was set as 5 minutes by default you can change it as per your needs so let me go to work item over here and change the status from doing to done it's save so the query that we were using let's go to the query P1 task okay and let's go to editor as for the query if there is a priority item of one value so we did not add the Clause of the status of it right so ideally we should have so let's add one more clause which says select uh State and State should be done and the operator we should use is this one which means not equal to done so if we do that it should not pick any task in the query so let's save this query okay and now let's go to results so there are no results at the moment we go back and let's see if it evaluates that in next 4 minutes we need to add one more permission so that your pipeline could access the work item so for that you can open the work item query in new tab okay and select the query the three dots uh in front of the query and go to security Now over here you will see your user at the bottom but this is not what we need this already has the allow permission what we need is uh you need to search your project for me it is YouTube clone and search this particular user YouTube clone build service and the name of your organization this step is really important otherwise your quality Gates will fail right so I'll select this one and make sure it has read permission set to allow okay this is done now let's go back to the build Pipeline and make some changes and as soon as I save the pipeline it should trigger the build and Then followed by release pipeline so let's go to our pipelines so it already triggered the build pipeline click over here and it's still in progress it will take a couple of minutes and I'll just fast forward the video from here okay so it has completed the build Pipeline and it generated the artifact as well now let's have a look at the release pipeline it should have generated a release as well so here it is and release is in progress so it says the quality gate check has been succeeded because our P1 work item was closed already okay so it evaluates the gate for consecutively two times and once both are green both are succeeded it proceed further to do the deployment so let's see the deployment steps it is currently doing deployment to the staging environment um the details are over here here you can see the logs so I'll pause the video here and let it finish if you are getting value from this video I would really appreciate if you gives it a thumbs up and subscribe the channel if you are new here so in about 2 minutes the deployment to staging environment has been completed and let's quickly have a look at the link by going from here and if you see the URL is this one and the URL has the keywords staging so that means this is a different URL than our production environment right so this is the application that we have and let's go back and see the next stage which is Brad deployment so we are at a release over here let's go to Pipeline and now for the prod deployment now it is asking our approval it when I approve it only then it will proceed else it will just wait for the approval because this is the deployment gate that we have added I can approve it from here or I should have received the email as well okay so let me open my email okay so this is the email that I've have got it says predeployment approval pending for this particular pipeline for this release and for this stage right so pipeline release and then stage this is how it is showing and here is the view approval button so I just have to click it so let's click it and it will redirect me to the page from where I have to approve it so here is the approval button click approve I can just say looks good to me and hit approve okay it's approved and go go see the logs it is also quaring the work item and let's quickly see what do we have in our app so I'll just copy copy the URL from here paste it over here and remove the staging from it okay so this is our PR version it does not have anything deployed yet and if you see this is our staging version we'll wait for it to finish and then I will show you the next steps okay so after a few minutes I see the predeployment approvals were completed Gates was completed and then agent deployment was also so completed in 1 minute 308 seconds and if we go to our URL this is our production URL if you remember so if I hit refresh now it it has the new version of application deployed right so this is our staging version and this is our production version right all right so this is what we have done so far developer did the git checkout and made the changes in and the local copy of their local branch and then they push the code to Azure repos G with the help of a pull request right and which triggered the Azure devops CI pipeline this pipeline has one build job and what what it is doing it is getting the details from Azure repos G all the files including the pipeline code then it performed the steps in sequence npm install npm build and then publish R effect once that is done the job is completed it triggered the release pipeline over here and then release pipeline will get the artifacts from the build that was completed it performs the quality Gates check uh by quaring the work item and then it deployed it to Stage uh with the help of azure app service slot so this is the green slot now now after the approval it deployed to production on the uh production slot and this one over here is the blue slot right so now we have identical copy of your production uh site in fraud and test as well when you have to do the changes you perform the changes in your test environment let's say over here and then you make a swap right swap as in you swap the application DNS and your application your live application will be now pointing to the test version so let's say here is your blue app here is your green app they both are identical at this time blue has version 1.0 and green has version 2.0 which is the updated version so you make a swap and then you made this as green and you made this as blue right so now your blue application is running on version 2.0 which is the latest production version what is the benefit of doing it is while the application deployment is in progress there is no impact in the application availability your users will still be able to access through the older application version and your application will be available by making a swap right so let's see how we can make the swap so I'll go to my Azure portal over here okay let's hit refresh over here first now you see both the applications are running but the traffic is 100% directed to app one now over here there is a button that says swap click on that and now you can make the changes over here like source is this and Target is this perform swap with preview you can select this one or you can directly make the swap so let's disable this and hit swap Viet is making the changes let's see if your app is still available both the apps are still available okay after a few seconds it says successfully completed swap between staging and prod let's close this and now you see uh the traffic is still directed 100% to this but the application has changed so you should be able to see the changes if you had made any changes like I haven't made any changes to the application itself that is why it is showing the same version on on both the URLs but please test it out by yourself and let me know if you face any issues so this complete architecture we have completed and we have completed the final step of making swap as well and this is how we perform a blue green deployment with the help of a cicd pipeline in aure devops
Info
Channel: Tech Tutorials with Piyush
Views: 7,463
Rating: undefined out of 5
Keywords: azure devops release pipelines, azure tutorial for beginners, azure devops tutorial, azure devops zero to hero, azure devops full course, azure devops tutorial for beginners, azure tutorial, azure devops, devops, build and deploy youtube clone, youtube clone, azure pipelines, azure devops pipeline, azure devops ci cd pipeline step by step, azure devops ci cd, azure devops ci/cd pipeline, azure devops ci, deployment gates, quality gates, azure devops end to end project
Id: acJErWFS15w
Channel Id: undefined
Length: 28min 52sec (1732 seconds)
Published: Thu Nov 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.