Deploy docker Image to App Service with Azure Devops ? Azure Container Registry with Build pipeline

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends my name is Vineet Arora and you  are watching azure devops series in this session   we are going to see that how we can deploy  the docker image to azure app service with   the help of azure container registry so  what we will do we will get a sample code   which is will be in python application  and there we will have a docker file   we will create the build inside our azure devops  pipeline and then once we will have the build we   will basically once we'll have the image we will  push it to the container registry and once we will   create the content registry we will deploy it to  app service azure app service right and this will   do with the help of service connection so in this  session we will see the practical demonstration   first of all we will create the content registry  then we will create the azure pipelines okay   so let's start before starting let me just request  you that please subscribe to my channel and if you   like this video please like thank you okay  let's move to azure container registry now   so now i am in the azure portal what i will do i  will create the content registry so you can search   for the content registry here and you will get  a resource basically to create a resource type   of content registry okay so now i'll click on  create and here i will choose the resource group   the registry name i need to provide so the  registry name i am going to use this one even acr uh location in central india now i will simply click it and we'll create it so now our azure container register is ready what we will do we will go to the we will go  to this resource now if you will see here we   have the repository section and here you can see  that there is no repository till now so once we   will create the image and we will push it we will  get that image here itself okay after doing this   there is an important step that we don't need  to miss that is with respect to access keys   and here we need to make it enable as an admin  user so once we will click on admin user we will   get the username and password now the thing is  why this is required this is required because   let me show you here once we will configure it to  the app service basically what we will do in app   service we'll just configure that box this is the  image name and this is the content registry now   you need to fetch it so how our app service will  fetch it our app service will fetch it with the   help of this particular credentials right okay  now so now we have created the content registry   it's time to create the build so for  the bill purpose i have a sample code   i will provide you the link in the sample code  of the sample code in the description as well let   me just show you that particular code where is it  so this is available here on this particular link   as updated i will give you the link in the  description section you can find it from there so   here we have a simple this is a python application  and this is just they are just two important files   server.pi file this pi file contain the uh  information basically the message so once   we will apply our application will start we will  get this message right and this is our docker file so once it will start it will we need to set some  environmental variable for the flask application   so we have already set it it will use the  image of python right and this will use the   pip install requirement.txt so  inside the requirement.txt we have a flask requirement if you will see so  we will use this flask application now what we will do we will simply build it  so for that purpose we will go to the devops   and here we will click on new pipeline  here i am going to use the classic editor   and what i will do i will use a github here you  may be need to authenticate with your credentials   now it's time to provide the repository name  so this repository name is public repository   so what i will do i need to copy this from here  after the slash to last i'll copy it and paste it now it will show you where the default  branch name so the default branch name is   main branch i will click on continue now here i need to provide the template so the  template uh i am going to use the darker one we   just need to use docker and we need to click here  as a apply so now if you will see we have the two   task build animes and push enemies so the part  of the what will the so what exactly the build   an image will do it will build the image as from  its name and the portion image will push the image   okay so uh here we need to choose the  subscription so we will choose the subscription   i have already created the two service to  service connection if you don't know how to get   the service connection i'll provide you the link  because i have already created a video for this   you may go through that and you will be able to  know that how we can create the service connection   okay so i am choosing this one now i am choosing  the azure content registry this is the registry   that i have just created and now we need to this  is already coming as a build an image and now we   need to provide the docker file so we'll click  here and we will give the link of docker file   now it's time to provide the image name the by  default image name is coming as repository name   colon build id if we want we can customize  it as well as our as per our requirement or   as per our project but here i am not going to  change it but yes if you want you can give it   any name something like ms hyphen okay so  let me give it as a ms hyphen here itself   right so now we will get the  image and build repository name   colon build id so this will be our tag okay so  this is the build part now let me just copy this   and now let me push it let me paste it  inside the section of image name here   here we don't need to change anything  other than choosing the subscription service connection and container registry  okay now we are done we just need to save it   and run it before that let me just choose  the ubuntu latest as a agent specification okay i will save and queue it so till the time it is building let me just show  you we don't have any repository here till yet   okay once it will build and push  we will get a new repository here okay it has pushed the image now let me just  click here refresh and now you can see that we   have a new repository and the name is this that  we already configured and if you will see the tag   the tag is 43 okay so we have a new we have a new  repository a new image that has been pushed to   container registry as your container registry  okay now let me jump here so we have seen to   create content registry we have seen this part  as well about the building of ms now it's time to   create the app service okay what i will do i will  go to the azure portal and here i will click on app services and here i will click on create okay  now what i will do i will choose the resource   group name and here i will provide the app service  name uh now as a part of publish i will choose a   docker container and then operating system as  a linux and here because i belong with india so   i'm going to choose central india as a region and  now i have already created a app service plan so   if you haven't already created app service  plan you will need to have a linux app   service plan here to save the time i have  already created and we are using it okay   now next click docker now here we  need to choose the container that is   which container that is the image source we need  to choose it so as because we have already created   azure content registry so what i will do i  will choose the image source as azure container   registry and here i have chosen i have not chosen  it is coming automatically as a registry part so   the registry that there was only single registry  so that's where this coming is selected and the   image name is coming auto selected and the  tag name as well it is taking the latest tag   so now thing is one important point here if  you remember we have enabled the access keys if you will not enable the apps access  keys here so here we will get the error   because this credential at the time of configuring  it it will use these app service these credentials   and this will configure it in its configuration  section automatically i will show you that as well   okay so now let me click on the next okay i am not choosing any app inside  i will simply review it and create it okay so now it is creating the app service  till the time it is creating let me update   you some important point that we need to  keep in mind those important points are   with respect to the uh some configurations  which are what are those configurations uh azure app service will pull uh let me tell you  azure app service will pull image from the acr on   a startup right this i have already told you uh  basically with the help of this devops we will   just configure it that applications application  will start it will use the that configuration   and pull it and at that time it will use the  credentials sometime we may face the issue   with respect to it with an authentication at  that time we may be in need to give the app   a service identity and container role we will  see that i will show you that as well if we   will get that issue okay the next thing is the  username password that i have already updated you   okay it has been created let me go to the  resource uh the important another important   point is configuration inside the configuration  i need to make it one thing that is as a general settings inside the general setting i need  to keep it as always on right and the next thing i need to click on save okay continue next thing  is application setting that i was talking about   here if you will see these are the registry  name registry password and server urls   right username so this is the username and  password that we are getting from the other   content registry so this is the password is  the primary password if you will see here   this is coming here so this has been automatically  set up okay now let me browse this application okay till the time this browsing let me  show you the logs as well here inside the   section here we have a lock this is a very  important monitoring tool which help us to   know that what is the status of image how it is  going how it is pulling from the image source   right it may source in the sense because this  thing i was talking about here we have con   once we will configure it so it will push it  will pull the image from the content registry   and that all lock we can get it from  here itself inside the log stream okay there's one more important configuration  that we need to add that is website container   start time limit okay and what we will do  we will go to the configuration section and here we will add it as a value of 1800 now we will  click on ok and we will just save it okay now what we will do we  will go to the locks once again and we will see that how this going okay so we can find that uh this  the log application is started   and now we can see that our application  is ready and this is running   so this is the content that we were  expecting on the startup of this page   right and here is the log and here you will  see that every time whenever i will click   on this page i will get the log let me refresh it  and here i will get a new log with respect to it right this one i have recently got so in this  way we saw that how we can deploy the application   without using the azure devops but now it's  time to deploy the image with the help of   devops so what i will do i will go to the devops  pipeline once again and will add up one more task   right here i will go to this part  and i will edit this once again and here i will click on plus and i will  search for container so now i will search   for azure web app for container and will add  it so here now what we need to do basically   till now we have done the deployment directly  there was no specific deployment this was just   at the startup of the application that we  configured now we need to configure the diaphragm   with the devops so here we will choose the service  connection and we will choose the app service name   okay now we need to give the image name so here  the important point we need to keep in mind we   need to give the complete image name like even  scr that azure is azure cr then dot io slash   image this is the image name that we have created  here ms hyphen right build repository name colon   build id so this is the same thing i'm giving  here so now i just need to save it and run it okay so this running now so now this is doing  the deployment on azure web app and here if you   will see the logs you can find that it is  updating the configuration settings right   and here it is giving the image name as even cr  acr.azure io slash image name and then at last it   is giving the tag name that is the 44 and that  this 44 is coming from the bell id itself okay till the time it is doing the  updation let me also show you the uh the source thing uh let me show you the content registry  so here in the content registry   now we will get the two image right and  here we will go to the repository section   so this is the repository and here we  have the two images when is the 43 and   another is 44 and this 44 is coming  from this particular this particular   build right this is the  build id that has pushed it   and now here if you will see it it is  taking some time to restart the app service and now it is stating that it  has been successfully updated   okay and here if you will see the  log that is you will find that what is the log okay and here you will find that it has  successfully downloaded it once again   and if you will see the ah we will browse  it once again and we will that we will that   code here itself that particular content here  itself okay so this is coming so now to get it   proper tested what we need to do we just need to  change the content of this and we need to run it   once again so in this way we saw that how we can  deploy a particular docker image to the azure   container registry basically azure app service  right this diagram will help you a lot so this was   for this purpose and i am here ending my session  let's meet in another video so let me just request   please subscribe to my channel so that you will  get the latest update of my new videos thank you
Info
Channel: Avin Techno
Views: 24,566
Rating: undefined out of 5
Keywords: Azure Container Registry, Azure Build Pipeline, DockerAppService
Id: 7qyWriiUenw
Channel Id: undefined
Length: 18min 39sec (1119 seconds)
Published: Sat Jun 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.