Azure Devops YAML CI Pipeline | Learn YAML for Azure devops pipeline | classic pipeline to YAML

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys my name is vini tarora and you are watching azure web series so in this session uh we are going to cover ml yet another markup language in my previous videos i have covered how to create the build pipeline with respect to the classic editor and there we have used the code as a reference as a basically i have create i have this code that i have already marked as public and you can download it from the github the description i will provide in the link itself and in my previous video i have used the reference of this repository itself right so this is a track so in my previous videos i have covered i have included the cie pipeline with respect to this repository and there as i updated i have used the python code and with respect to python i have used the docker so in our docker in our ci pipeline what we are doing we are creating the uh we're creating the build from docker and now we are going to learn it how we can do it with ml so let's start before starting let me just request you that if you are not subscribed to my channel please subscribe and please like this video thank you so let's start okay so as updated this is the free code right you can easily download it and you can use it in your own github depot and here we have the docker file and this docker file is creating the image this is a simple code now with respect to it classic pipeline we have the four task first task is basically build an image another is push an image then we have the deploy part right and here we have used the two part basically one is with respect to dev and one is with respect to qa that we have already seen in our previous video that how we can deploy it as per our environment right because the code is available at one place but now we want to deploy it to place depending upon the feature feature branch okay uh so what we are going to do we are going to create ml file so let me click on the pipelines here if you will click on the new pipeline we have the two option to create the pipeline either from the ml you can see all these options are coming from the ml and all these option and the and then we have the option of the classic editor in the lower part so the standard way to do it with respect to it ml file itself right there are multiple advantage of using the yaml uh with respect to yaml basically what it is going to do it is going to create a yaml code yet another markup language code which will be added in a file and that file will be the part of your repository right so here we have the repository let me click on code and here we have the repository so what we will have we will have the one more file that will be the yaml file and the reference of that vml file will be used here okay so we can have multiple ml file and we can use the file any file there so let's start let me click on the uh basically first of all it is asking where is your code so our code is on github i am clicking here once i will click here basically it need to create a link between the azure devops and github so it will ask me for the username and password so i need to login here okay now i have logged in so here it is automatically showing us how many repository we have in this particular github account i have the two repository and the repository that i am going to use is this hello docker hello world flask right this is a hello world application which is in docker and i am using the flask as a server so i will select it so now what it will do it will automatically scan our code and we'll know okay that how what is exactly i can propose you so it has already scanned our code and it has find a docker file here in our route so it is proposing us that boss you what you can do you can create a python package or docker file basically uh you can use the docker task or python task because we already have a docker file it is proposing us to create a docker all right and we have the python package what we can do we can use the python itself and the other is and the option is the starter pipeline so in these options it will give us the sample task already it will populate it in our file but in case of starter pipeline it will not add the task with respect to docker or python getting it so what i need to do i need to choose it either this or this so let me go through with this docker first and then we will go ahead with the starter as well so let me click on this builder docker image and it is asking us where the docker file it has automatically populated that this is available in your root directory so let me click on validate and configure so now you can see that it is proposing that we have uh it will create a file the named as azure pipeline that i updated you earlier and that file the content of that file will be this right and when we will actually go to save it it will ask us that where exactly in which branch you want to save it okay but before that let us understand that what exactly this code that it has created for us uh for a reference because initially i went through with this classical pipeline let me go to the classical itself that i have already created so this one we are using let me edit this so here we have the multiple task as i updated initially so first was to select the code that we already choose now the part is build an image right now as i updated initially that we had multiple ways to do it so i am going to define you here so if you already know that whatever will be the first task right because you are a diverse person and you are going to build a pipeline so first task will be build animes so first option is as it is already proposing that the task will be talker 2 docker 2 means uh the version is coming at that is 2 2 means version okay so as similar to here what it is doing it is first part is a trigger part trigger part means when this particular pipeline will be executed means for which particular branch so this particular pipeline will be executed for main branch so whenever we will have the changes in main branch if we want to get it done for any branch what we can do we can use asterisk we can remove it and we'll in double code we will use asterisk number one point okay another point if we want to get it done with respect to the multiple branches so let me press enter let me add hyphen and then let me add one more branch name here so in a way we can do it right however if we want to override this for example uh if we want okay this is the trigger point we have added in our ml file but if we want that this particular trigger point should be override so we have that option as well and there so let me tell you uh in the pipeline section because as of now this is in classical way but in the pipeline uh when this will be the yaml way we will have the option here the trigger will click on the trigger and there we will have the option to choose the so this section will overwrite the uh content of trigger content of basically this particular file okay okay let's move to next next to the resources so it is asking that what i need to do i need to create the repository and basically i need to check out the repository itself then the variable section this is the important section basically we need to know what exactly the variable so in our pipeline if we are looking to have some code or some value that we want to do it again and again that we want to use it again and again we use the variable so here what it is proposing it is proposing us that let's have a variable named as tag and there it is using the build id right we have already seen that what is build id so this particular tag will be used at multiple places in our task right so let me just search control f dollar bracket start tag so they are using it here okay in our pipeline what we have done let me show you we were building an image and here we need to give the tag this is about that part basically you can say here so this is the value we are if you will see that we are replicating this value again and again we are basically doing the same thing right but here what we are doing we are just defining it one place in our section in classical pipeline we could also do this in a way like we what we need to do we need to go to the variables we need to click on one value as a add we need to add as a tag right and we need to add this value as a dollar bill dot build id okay so this is the way to do it in ah ml and this is the way to do it in classic and here if we will in task what we need to do we need to just use the variable what we need to do let me cut it okay dollar bracket start tag and and here let me paste it uh excuse me trigger point sorry variable point so here like this okay so in a similar way what i am going to do i am going to use the tag here as a the complete one that i am going to use okay the name can be anything this can be tag or this is user defined it is up to us but we are going to give the name right let me give the name as image name why i am giving the image name because actually i am not using the it as a tag tag is this value which is coming after colon right so this is a complete image name which is with tag we have already seen that what it is it will basically go with the image name image hyphen repository name then colon branch name and then build id okay uh as a next step let's move to next step we have the stages but if you will see we are not having any stages in our classical way so here we have the stage the first stage the bill we are going to because in our yaml what we can do we can have the uh stage as a deployment as well right we can have the multiple stages we can have the stage of bail we can have these stage of deployment but here in our way what we are going to do as a first step i am going to show you how we will go ahead with the build and deploy as a one so let me click on the build and deploy because this is the this is the docker way to do it right so as the build will be as the particular image will be pushed right so then we will fetch it and then we will use it so here let me add the display name as build image and deploy right okay now we have the jobs so first job is a build let me add the builder i'm i what i am going to do i am going to make it very simple i don't want to get you confused right so i am going to in a very simple way the simple task i am going to edit and i am going to replicate in the same way that i have done it in the classical way okay so the display name is build so let me just add it build and deploy as well we can give it any name no issue about that now the pool pool is basically which particular image it is going to fetch on which our code our this ml code will run in classical way we have this option here in the pipeline itself when basically pipeline is start we have the options like what exactly the is end right so here we can choose we have a number of os we can choose so here we have used the ubuntu latest and in a similar way we are using as ubuntu latest now let's come to the another important part the most important part we can say the task so now what we need to do we need to create the multiple task sorry we need to create the task as per our requirement what exactly is a requirement so our requirement is to first of all to build an image then push an image and deploy in dive environment as well as production or we can set in a qa so we have the four tasks so first task is build dynamics so now what we have done is here we are building it so in a similar way uh as your devops this has been this has proposed us so what you can do you can build an image now what i can do i can either changes i can do the changes in this particular task or i can create a new task or i can copy paste it from somewhere this is a very important thing that you need to understand let me rewind this what you can do you can either change the change here itself or you can copy paste from somewhere somewhere in the sense from here or you can create a new task so how exactly i am going to do this first of all if i want to change anything so if you will see what i have done here i have used the version as a zero right we have the zero one two here the three version and this is the you can see the part which is coming up the after at the right is the version so we have used the version zero so let me choose the same right now display name this display name is this name which will come as a build animaze so the same thing is coming here no change required input what is the input it is saying that input is a bill and then docker file is this and then tag is this but the important thing is that you need to understand basically this is the editor this is the yaml editor that is governed by azure devops microsoft and this is a very helpful tool so here this all about yml file is all about identitation right so here if you will see from the starting light everything is from the orientation there is no curly braces there is no tags as into xml file it is simple plain language which works on basis of identitation or tabs so first was the trigger next for the resource next for the variable now as we will add tags tags means this is our tab no text tabs as we will add tabs or the identitation that means that particular property is coming under that particular uh main thing main tag for example here we have the stages under this is we have the orientation basically this this stage first stage stage and then after you can see this stage the display name is the part of stage itself then jobs is the part of this uh this particular stage jobs right we have the as a part but we need to we need to add a hyphen and then write it and then these these are the three properties job display name and pool these are the part of jobs now further we have these tabs under the jobs and there again we have used the ah task here and then we have used the orientation then if you can see these are the part of your for example command docker tag this is the part of input now the important thing is what i was going to tell you it is about these things this is coming as right orange line right which is not correct basically it is showing us that this is the warning what is the warning let me show you here it is saying that unexpected property command actually it is stating that this is not the property of your docker task docker of version zero let me do it too now it is okay so basically this is displaying it as a part of our version itself so it has the intellisense it can know okay which version you are using and how exactly this is working let me click on the zero uh let me remove this input part because this command is not the property of here right docker file is this that's why it is showing us let me remove the tags as well okay so now i was stating there is a multiple way to do this so one of the way is either click on the settings part this is there we will have the settings option under each task if so if i will click here i will have the options here to choose right first option is coming as a where is the registry i am stating that this is in azure content industry right whether it is coming as a by default as your subscription what is the subscription so this is the basically service principles so when we need to use one of the service principle uh because this is one of the topic that i have already covered in one of the my video where how to create the service connection and what exactly it is so please go through it i will also provide the link on the top as well as on the description section another option is uh let to add it from the scratch so let me remove this task this will give you more understanding about the ml right removed let me press one more back okay now my cursor is here now what i need to do i need to press on enter i need to it is automatically suggesting us that what are the various properties we can use here now let me press hyphen as a next property and press space what i need to do i need to use the tasks so i will press t then this will automatically come here as a photo suggestion and it i will select a task then i will press curly brace and then enter i will pass a colon then we'll press enter all right uh so under the task what we need to do we need to have the further more properties or what i can do if i know sorry and as i will click on the colon i need to add the name of the task so what is the name of the task if i already know the name of the task but i can know okay i will select docker then add the rate 2 right in a similar way i can do it if i know the if i know it i have pressed space this is the another thing we need to have the space here i for colon so once i have pressed this space it is coming us as a settings now this is okay and if i click on settings it is proposing to add the properties what you can do okay let me do it from the task itself from the editor itself now let me press enter and let me press one tab space and now next property which is which you need to choose as a display name so this is the basically the important thing is this should be an orientation of this particular task and because these are the property of this task and here we need to choose the display name we need to add the display name so let me add the display name as what is the display name the display name is build an image okay enter next value what we can have we can have the inputs right we can have all other these things so let me just demonstrate you hey from uh our pipeline section uh in our classical way build an image so here we have these all these options right so in a similar way we will have these options okay so these options will come as an input these are all our input right display name is one thing and then all of these things are is input this all this will all these things will come in input okay so now what i need to do i can add more property if i know okay as an input let me click here it is automatically now i will control escape it will add me it will show me that what are the various properties i can add the docker file if i know i can choose the value what exactly the docker file uh i can choose the uh right docker file right here if i know okay but here the thing is you should know exactly you should be well aware okay what are the various input that i need to use but that is not the case you will not be remember it every time so that's why uh azure diops has provided as a setting section so what we can do we can add the values here and we can move ahead right we will click on add and we will have the values okay so this is another option and now the most another option is this this was one of the option let me tell you the other option now i am the steps let me click here on the back right so now we have the option here as a task we can select it from the list how it is coming it is coming automatically from here i have a hide assistant and show assistant tab here i will click on the hide show assistant now i can choose the task as a docker but i need to choose i need to choose a docker and i i need to have the values from here and i can work accordingly right okay this is another way this is the second way the third way is what i can do if i already have this classical pipeline and i just want to replicate it there what i will do i will click on the view ml and i will have all these options from here right what i can do i can simply select it i can copy it and i can use it this is showing us error because this is not in correct orientation of task so let me select it and press tab one more tab now this is not coming okay this is an important thing we just need to be aware with respect to it okay so now if i will click on settings and this will come here as a auto selection right and if i click on add so this will update the value here okay so now let me click on settings again okay now let us come on the current properties so the first of the property is azure content registry next to the azure subscription that we need to choose here we have the options to choose either manual or automatic these two both service connection i have created and if you want to know that i have how exactly i have created please go through my previous videos i will provide the link on the top as well as well as in the description all right so we have the manual we have the automatic i have chosen manual here now the let's come to the content registry so here container registry it will automatically populate and the value will come we need to select it as a even ser now the one important thing is if you are in the azure container registry you will see this is not coming as a even ser right this is you can say this is just uh uh one of the it is name of this particular so here we don't need to use even a cr the name of the content registry we need to choose it and automatically it will add the values if you are not working on the uh on your property section from here you need to add this in this particular way like what is the login server what is the id ah so we have the two options login server and id for the user content registry next thing is action what is that action action is built in amaze what next thing is file okay the file is docker file and then image name image name is coming as a tag because i have just copy paste it from there so what i need to do i need to use this image name copy and paste here okay now let's come to the next part or next task what i need to do now this is this one task is ready right the important thing is we need to concentrate on the properties on the input here itself okay if i will press enter it will auto select it the auto selection will be on behalf of the input but exactly for the properties i don't want this let me click on back now i am in align with input so as a similar what we have the options i will press ctrl c uh control escape and i will have the further options like i can have the condition continue error and all those stuff okay i don't want this let me press one more back now ah if i will click here so now again this is the uh this part is coming as a task here so now i can add more task here either as i stated earlier i can go to the task property from here right i can choose from here or i can copy paste from here from this particular portion image if i already have a ml or i can simply copy paste from here ctrl c ctrl v ah need to take care of adaptation right this is done now okay the again version is zero display name is push and image okay i have a i have copy paste of this here i can change the name here now input is contain registry type subscription action now what is the action i need to choose the action as a push an image but because i have copied paste of the above one that's why all these things coming here so either i can change the value from here like this or i can click on settings or i can update the i can select the values from here the important thing is here if i will choose for example i am not going through it with this particular uh section i am just choosing any value i for example let me do some mistake now it is showing us as a warning because it is showing that this is near in one of the list for the action this should be in one of the list right although this is a string but this should be coming from as a list so i will need to click on i choose a push or need to go through the settings next thing is docker file docker file is this an image name is this okay we should aware of this thing but exactly we have the properties here so best thing is this click on the settings now you will have all the options choose from here and click on add right or this is one of the option another option is from the copy page as i was saying earlier click on the view ml here now you can validate we have the azure subscription container registry action and image name we are the four property subscription container registry action image name subscription container registry action and image name because this is the part of your uh push an image and here basically you are not getting the docker file because here as it is the task of pushing image we don't need to work up on the build we just need to push an image so we need to choose where is exactly the registry where this is an azure we need to push it we need to what is the image name so here there is no use of this particular docker file let me click on settings here itself it is not showing us this option right we can remove this so that's why i was stating the good thing is click on the settings and now we have all these input and we can click on the add and we will have the related properties here okay with respect to version if i will add it as a 2 then as stated earlier this coming in orange basically and if i click here then now this is the error basically that's why this is not choosing us it is not giving us the options to do all of these stuffs because it is a different property right with respect to version 2 let's go ahead with version 0 itself and now we are done okay the other task is with respect to the deploy part uh as a sake of fake as a sake of time let me just copy paste it the good way or and i have already given you that what exactly we can do we can either create the task from here we can choose if you know you will simply click on the here we will simply go to the docker right now current related task will come here right deploy uh we know what is the task we are need to use we are need to have the azure web app for containers so what i need to do i need to search here as your web app for containers right i can choose it and i can choose the values from here like what is the subscription value uh right subscription is this docker app name app name is even docker dev so if i will click here it will uh it need to show us the app name okay this is automatically populating from our azure which is linked with subscription i have chosen the app name now the image name what is the image name in a similar way i need to choose this or as that dollar image name so what i need to do dollar bracket start bracket and amaze name right and the next thing is uh any any other further property we need to add no we have not added further things okay what i will do i will simply okay we have one more thing that i am missing here uh as a control option right so control option it is one of the also the property it is stating that if the branch name is dev then this will deploy to this particular app name so this particular task will be executed if i have the option i have the condition here this right so i can so the thing is we will not have the option here let me choose we have this or not right we are not getting any option this is one of the important thing we need to understand if we are going it through with a variable section through a property section we are not having this option we need this need to come under not as a input because this is not the input this is coming as a part of this task itself right that we need to choose manually let me show you how see condition name not coming here click on back now it is coming as a condition i can press enter and then what i can do i can copy and then in the bracket i can add this value uh okay i need to do this this is the proper this the editor which will show us that what exactly the mistake you are doing it right this should not be in red or in the warning stage so uh this is another condition so but this condition was not applied here this was with respect to the azure web app for container so let me remove this let me add this now it is added for us let me press one tab now red is no more now i can have the condition back condition type here and then well paste it so this is the way right so one way again i am just rewinding it again the another way is click go here click on the view ml simply ctrl c and and go here and let me remove this paste select it tab one more tab now this is okay now we have the subscription app name container condition now we can update it either click on the settings right if i will click on the settings part it will automatically ah select it that what exactly it will allow us to choose the properties right and then we will go ahead uh but as i updated earlier we are not choosing the we are not giving the values as a hard coded so okay the another thing is now we has an input the input is coming here as a even acr dot io slash image name so this is the complete image name the in our containers when we are doing the deployment we need to give the complete path so here uh this is the value that we have used starting from here image uh bill repository name build source branch name and bill build id so right this one now we need to continue concatenate how exactly concatenate we need to have this value we will remove this all from starting from here to and we will add dollar bracket start bracket and this way okay let me in this way again right so container name is evins here azure is ah even scr as your cr dot io slash image name let me show you from here this is the complete same value coming here right ms build repository name same value so that we are using as a variable okay okay uh so this is done let me either same thing copy paste from here for the sake of time let me just click here and then view ml let me ctrl c let me just do it fast paste right selected that which we should not have error this warning is coming as error now we have no more error this is done let me just update the container name uh okay and paste now the app name is qa and this is now done now what i need to do this is now completed as per our requirement our requirement is to do the deployment along with basically to do the deployment with build part as well okay so it's time to save this file what i'm going to do i'm going to click on save once i will click on save it will ask us for the commit message as well as it will ask what exactly you want to where exactly you want to commit this so what i will do i can either choose a main branch or i can go branch let me go ahead with the feature branch right why not we are using uh let's use the options that we have provided okay so i am click on this start as a pull request okay uh i'm not clicking on the start at pull request i can create the pull request from the uh from there as well from github as well okay now the which it is asking us for the branch name let me add the branch name as a feature branch right and let me click on save okay what it will do it will basically create a new branch for us in our github repository here we have the two branch main and dev now we will have the one more branch which will be as a feature branch and there we will have the file okay so ah let me click on the you will see some error here don't worry about this because this error is with respect to our trigger point because what we have done we have chosen as a trigger change file we have chosen that our file is in uh feature branch but that it is starting to it is trying to fetch from the feature branch so that's why this error is coming so don't worry about this let's go to the github let me refresh so now it is stating that one more branch we have let me go here and now we have the yaml file here itself right this commit message is coming okay either we can merge this to the main branch now or we can as a part of testing because you are a developer you are a davos person and now you are doing the development of your eml file so what you can do you can test it with respect to feature branch itself why too much because in our general practice we need to raise a pr and that will be approved by our uh team lead and for the architect and then that will be added so let's not do that let's click on the pipelines and here let's if you click on the all here we will have the one more uh pipeline that is coming as a this one which we have created just okay let me just select it and it is showing us the error basically it is not allowing us let me click on the run pipeline so here as stated earlier it is basically the problem is it is not finding the ml file and it is trying to find the main that is not good this is in our feature branch if i will click on the feature and now there is no more error if i will click on run right and then if i'll click on run then this will execute it what exactly it will do it will further basically do the deployment before deployment it will do the build part and build part it will create the image okay so here you can see that build and deploy this is the name display name which is coming here let me show you from the uh ml file itself now i am the i am on the github and here if you will see here the display name is coming as a build image and deploy right uh build image and deploy uh uh uh no this is with respect to the task build an image right so this is the task if i click here this is the stage which is coming as a building agent deploy and here we have the task here what we need to do we need to give the permission i will click here view and then permit basically asking us to use the service connection i will permitted that boss yes you can go ahead now it will execute all the tasks for us okay so this pipeline has been executed and as you can see from the screen that all the tasks have been executed other than these two one right so why these two tasks has not been executed because there was a condition that condition didn't matched the condition was that this particular task should be executed when the particular branch is either main right dab or main this was the dev task because this was deploying the image right and this was deploying because here we had the main branch so that's the reason it did not execute it okay if we want to execute we simply need to update the condition so in this way we saw that how we can have the ml file how we can have the ml code for azure device pipeline right and we can have these stages there and can we can have the jobs and task okay so now we have one more way to do the yaml what is that way that way is coming into the picture when we already have a classic pipeline right and when we already have a classic pipeline what we can do we can export that pipeline how let me show you uh as you can see from here i have this particular pipeline which we have already executed and let me edit this as you can see from where this is the classic pipeline so what i can have i can have the export option uh where we can have let me just check it okay uh here we will click on the triple dot right and we have the option either to export to eml or export to json if you will click on the export to ml it will download a ml file and then if you will open this we will have this content right so this is already ready content ready code that we can have what we need to do we simply need to copy this content right ctrl a ctrl c we simply need to go to our to our code right this is my repository let me go to the feature branch here and we can have the new branch as well so what i can do i can have the new file here create new file and the file name can be something like azure devops i already have a uh one email file so i am giving it as your devops tool and what i need to do i simply paste the content here right so now this is ready to use code if we already have a classic pipeline and if we want to use that we will simply click on the export and we will have the ml content and then we will use that right and in this way we can have the ml ah so here we saw that how we can have the different ways of code different ways of eml right so ah let us end our session here and we will meet once again with our new session to learn something new in azure devops thanks a lot thanks for watching and please subscribe to my channel thank you
Info
Channel: Avin Techno
Views: 7,632
Rating: undefined out of 5
Keywords: azuredevops, ci/cd, yaml, continuousdeployment, continuousintegration, yamlpipeline
Id: TMtSbudSAVQ
Channel Id: undefined
Length: 43min 11sec (2591 seconds)
Published: Tue Aug 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.