Azure DevOps CI/CD Pipeline Build, Push Deploy to Azure Container Registry & deploy to Azure Web App

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] CD pipeline from the scratch to Azure devops repository and we will be able to build an image using the docker configuration and push that automatically to the Azure a container registry and after that we will set up the release by applying to automatically deploy the newest latest image version to our Azure app service and I will be using the existing two application that we will be seeing for the last couple of videos and which is nothing but the task manager API under task manager web app come let's get started alright so you see this there is this application that we were discussing in the last couple of things so we have a Docker file and the docker file has the information so what I'm going to do is I'm going to split these two applications into two different repository so I will be creating the repository under my learn smart coding uh login so here's the first one right so we have a task dot API I'm going to clone this like I'm going to do everything from scratch like as if there are first I'm doing this so this is my code which is present in this folder so what I will do is I will open up this folder using this way if I do a CMD of exe it will open up that folder into my command prompt okay now here the first thing that we will do is get init we will initialize the get and then what we will do is we will add the new GitHub repository uh remote origin to this folder so that I will be able to push all my stuff local information into the Repository so in order to do that I'll be using the next command called get remote add origin that followed by the original name git add space dot will add every single file that is there inside the folder everything is added and you see this green color that's the one that you will see when you do a git status now these are the new files that's why it's green color right it's very first time so what we will do next is uh we will do this git branch and do uh to the new Branch like we will push all this content to a new future Branch call features loss initially uh or maybe initial code probably that will be the good name of the branch so I created it I'm gonna push all this code to this Branch then later we will do a pull request and merge the code okay if you have not seen this how it is happening this is how the new code will be pushed to the repository whether it is GitHub or devops or anything this is the way right so once I do this commit git commit Dash M there's some states for the message and in the double course you put the message and then get push origin head that's it every single code has reached this location and you it also showed me output request is ready so I'm going to create a put request merge to the main branch and keep the uh branches clean I deleted whatever the feature Branch was there now just the main branch right so similarly we will do this to the web app also and push it to a new repository called task manager dot web app okay all right now our main branch has the code okay now this one is the one which has the docker pair also so now what we are going to do is we will quickly create a web app so in order to create an Azure web app service so here you go you create a web app in the Azure portal and start filling up this information so here the subscription the resource Group I'm using your existing Resource Group in the name of the website should be unique it should start with your name I mean the application name and Then followed by it will be Azure websites.net so in our case I'm going to put this as LLC um task manager API all right so I'm going to use the free version like I said most of the stuff are free in Azure you can just need to use it I'm going to use the iPhone Dialer for this demo this is more than enough now this is important we choose the Linux as the container and you know the container as a solution the Linux is the OS version the next version that the next tab is the docker one if you leave Asus it is the default Docker version is deployed from Microsoft and you will see how it looks later we will use the cicd pipeline too um you know deployed through the pipelines now all these things are like as usual the regular one the size and when it is getting deployed what we will do we will be able to launch the application and this is what happens right so this is the default version that is done now the one that you're seeing on my screen is the container registry cost okay so when you create a container just in a view this is the cost that will incur there are three types the basic standard on the premium we will go with basic because it's the least amount of price per day and 10 gigabyte is more than enough for us for our demo um so I'm gonna go and create a container registry so what we will do is we will search for container registry and you will end up going to the Azure content registry click on create container registry so in this case I'm going to put all the resource into the same Resource Group so later I can delete it if you don't want and the resource Group is the docker demo RG and here this is important instance details right so registry name you remember it has to be unique and it will be you see this learn smart coding which was already taken by myself on a different account so I will choose this as uh learn smart coding ACR or maybe maybe something meaningful as CR right CR means content registry now that will be the uh the name of the registry okay and then location is East us and then rest of the stuff I'm going to leave it as it is for a basic version you much don't have much uh options to modify it anyway we create this thing and then a few moment it will be done you'll land here this is the overview blade and uh if you go to the access key right as I spoke in one of the video this is uh the admin credential and under the repository you will end up creating a repository and the image tack here which we will do through the CI pipeline now this another thing called uh Access Control okay so we will be doing the access control uh so stay further for a second so now let's come back to our devops login and then uh click on this new Pipeline and start choosing whatever the application uh repository and here the second one is the docker version so once you choose the docker version it will realize that you have a subscription and it started showing me the subscription so I will choose that and I will click on continue so once I do this it will ask me to re-authenticate okay I will re-authenticate with my credential it is going to send me some notification using the Microsoft authenticator so once I choose this you see this container registry started loading up here and then the image name right so image name uh we will name it as a task manager API this remember whatever setting up here will be the repository name that will be created so the image name is Task Manager API and it is now analyzing the project and the docker file that we have and it is trying to generate the yaml file for us very good no I don't need to do much of the information so it only triggered so now if you look at this file it says the trigger criteria is main branch and then it has a bunch of variables the the the service connection the image repository you know all those container names so if you look at this container name right this is the container name that was automatically invoked learn smart coding CR dot Azure CR dot IO now the build will be the build attack ID which will be incremented number and then here you will have a task uh display name this is all generated code but trying to understand what it is doing us it is doing a build of a Docker file that is there in the project this yaml file is just pick up the docker file and Docker file have information about how to pull the base image how to get these packages installed how to generate an image how to tag it all those things right it will do once we have the image ready the CI pipeline will be able to get this image ready with the tag okay the build number see this is the bill number and if you remember when we set up we did a task manager API that's the repository name and then it has created a build and pushed it great it was so easy right as and when the code changes it will trigger automatically and uh finally it will be able to push the built image with the new tag number and put it into the Container registry now what I'm going to show you here is I'm going to go to my one of my class files and going to do an edit okay do not do this I am just showing this to quickly tell you that any changes that happens on on this main branch right uh will automatically do a CI trigger see the comment has happened on the main branch okay on the program.cs file this is not the readme file or any other file because of that the CI pipeline should have got triggered automatically so let's click on the pipelines so there's a branch see it's already the status is showing us in Focus if we go to pipeline the pipeline that we created started showing up the second one and the build is automatically happening if you remember 23 was the bill number and ideally we should expect an extra bill number as 24 uh unless there's some other builders running in my project but anyway we'll wait for few more minutes while this comes let's go to this a LSC task manager API and under the deployment Center what I'm going to do is uh whatever I did I'm going to disconnect and show you as as it was a fresh one okay so this is how it looks when you do it so right now it is container registry now what we are going to do here is we are not going to touch anything here okay like I said we need to have the managed identity admin credential is really not safe to use it it has more privileges we should not do it so we are going to see how to create the manager entity for our CI CD pipelines so that it has access to modify the container configuration the release pipeline should have access right so what we will do is um we will disable this uh go to access key and disable this admin access okay then in the search box search on managed identities you will end up here see I have already managed entity but let's create a new one and here I'm going to choose the existing group so all the results are grouped together and give a name here okay this is just to understandable thing see in order for the image to be pulled from the container registry for this for this application right it should have an access or ACR pool that's the role uh ACR pull is the role that it should have so that it has access to pull the image okay so let's create a name and uh we will create this managed identity we haven't given any role the name is learn smart coding CR pull image role okay container registry Pro Image load now the deployment is running up this resources ready go to this resource and to this left side there something called Access Control IAM click on the add role assignment here you can come and search ACR pool ACR pool is uh is one of the role as we can go or click on Azure role assignment and click on ADD role preview this is a new one and choose this Resource Group subscription and then here ACR pull pick up the role name and do a save what we are doing is the managed identity we have assigned the road okay the reason I showed you a signed role even though it is in the preview was by the time you look at this video they will all become a generally availability now it is very clear that this one learn smart coding CRP image role has a role called uh this one now let's go to IAM and select this see this the one which we already assigned is already showing up all right so the role is good so uh the manage entity which we have created have assigned a role which has access to pull the image from the Azure container registry so for good now we will use this managed identity to go unconfigure in our deployment Center let's go to this um LSA task manager API and what we are going to do is we will go to this identity user assigned one and click on ADD and select the one that you created it okay so once you select and do an ad what will happen this web app has an access uh to this managed identity okay so now it's all configured now what will happen if you go to deployment Center and choose the manage identity it will start showing up all the manage entity that is that belongs to this web app in our case uh the one that we have is learn smart coding CR so once we chose this managed identity and then you know do the build image and tag okay so once you do these two things you can save it so I'm just going to put attack number as 31 because a lot of bills has run and 31 is the latest bill so let's do a save okay we are not using the admin credential we we managed to use the manager entity this is a one-time thing once it was safe forget it now let's see how to build a release pipeline come to this devops go to the pipeline and click on release okay once you click on release to this uh so click on new and you will end up creating a new release pipeline now pay attention here initially whatever task that we want is not coming up here for me it didn't come up most likely it won't come up for you so if you start searching something called container nothing shows up right so just click on one of the tasks which is already there one of the feature which is already there and later I will show you how to change it what will be the final one to choose it right so I will choose Azure app service deployment and you will apply or uh yeah just pick up whatever you want for the first time so I will choose this as your app service deployment and do an apply we will change this shortly so go to this task and on this task right under the runon agent there is something called A Plus button okay so when we're going to create a new task here and delete the one that we choose there I don't know for some reason it's not coming up uh during the first one so click on ADD now and choose uh and search called container when you search on container there is something called Azure container apps deploy this is the task that we want uh so Azure web app for container is the task that we want I choosed it and I'm going to delete the one which was already there because we don't need it here display name is fine and choose the subscription that you wanted here and then the app name automatically the app name web app name with the container one will come if you have more than one container uh web app it will show up here now the next thing is we need to provide the the container name slash I mean the configuration that we did to push it right we will use this login server uh the name of the login server just learn smart coding cr.sucr.io slash repository name repository name if you remember uh if you go to repository this is the repository name that was created using the CI pipeline so task manager API so we will use task manager API and then colon here we will not do a hardcoding the build number is the one that is pushed as a tag into the registry so we will use dollar symbol build.built ID whenever the new Builder is configured that build ID was the attack number that will be used to deploy now we will change the stage as uh staging you can give the name whatever you want go to pipeline the next one is adding the artifact click on ADD rectifytes viewer build choose the project and choose the one that was the CI pipeline name our CI pipeline name was task manager.api I choosed it and here click on this and do an enable this is called continuous deployment whenever the new build is available a new release will get automatically triggered now bare minimum setup is done we will name this release pipeline meaningful task manager API release so like a stage little is okay on stage environment uh you can name it whatever you want so under that uh there will be a new folder that I wanted to create so task manager API and the taskman JPI this release pipeline will be created so say okay and then um you know we should be okay and then this is all saved let's go to release Okay click on the release you see this there is nothing created I'm going to trigger a new build and you will see as soon as the build is available the release pipeline gets triggered now click on new now click on the task manager 1 and do a run pipeline so if you do a run pipeline this is that you are manually triggering a build but like I showed you if there's any code change happens this CI pipeline gets triggered automatically and whenever the CI pipelines is triggered automatically and the builders available the artifact is available you see this the new release got triggered and in the staging and I mean once you click on the logs if you want to set up the approval you can set up that in the pipeline I have showed in one of my video but this case as soon as the build is available what this is going to do is it is going to take this number you see this learn smart coding CR dot uh CCR dot IO slash the repository name and the bill number and this pipeline is connected to the a web app of the container like lse task manager API that's the website that was configured right so it will go to this deployment Center and it will update the version once it updates the version the container will automatically start pulling up the new image because it was it was like you going to the deployment Center manually changing right that is what the release pipeline is doing it it the only thing that it will do is it will go and change the number as soon as the number is changed and saved the container will start pulling up the image and you can see that through the live stream called lock screen under the monitoring section as soon as the police pipeline is doing this you can see here uh number 34 should come here right 34 was the last number that was triggered I believe so 34 should come here uh this is one of the thing that you can notice under the monitoring section log stream that's a live stream that is giving you information so what I'm going to to find out here is 34 let's see where it is okay it's that's only in one place let's scroll down and do a refresh okay so this is successful I can see that and let's reconnect all right it's coming down and you see this the new image was built and it also says it is ready for reserving any request all right we can see that if you go to deployment Center it will change like this because right now now it's connected to the release pipeline so no more it will show you that unless you disconnect now all the cicd pipeline has been set up here uh both looks good all right I hope you enjoy this video and uh you know now how to set up the CI CD pipeline even for the docker images to be built and deployed to the Azure content which is free thank you and I will see you in the next video thanks for watching if you found this video helpful please give it a thumbs up and subscribe to our channel for more Tech tutorials and don't forget to hit the Bell icon to get notified when we post new videos if you have any questions or suggestions leave them in the comments below happy coding
Info
Channel: Learn Smart Coding
Views: 2,874
Rating: undefined out of 5
Keywords: Azure DevOps, CI/CD pipeline, build and deploy, Azure Container Registry, Azure Web App, automation, continuous integration, continuous deployment, Managed Identity, ACR
Id: v1HL-QnKSZA
Channel Id: undefined
Length: 21min 26sec (1286 seconds)
Published: Wed Jul 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.