How to Deploy Docker Containers on Azure with .NET Core api

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's get to start Demo First of web API deployment with single Docker container right so this is a hosting uh API if you see uh I can just if I try to get so I am getting that uh output over here right and if you check that another one like see this one and if you also check yeah whatever data is returning so this is a hosting in our uh Azor Azor app service and uh if you check in our portal now it is running uh this app service using that you know um using that uh container uh single container so that we will build over here right and uh we will use the both approach like we will use the CLI approach as well as we will use that visual as well so let's get start implementation how we can achieve these things like deployment in our aor uh using Docker single container right so before starting I'm especially recommend to you uh please watch my you know go to my channel like net real word example and here go to my you know Azor series whatever Azor series we have done like you know how we can use that pre credential free uh subscription of aor that is a very important to learn these things because as of now I am using same things like free free subscription so if you don't have uh asor subscription so don't worry you can take you can watch this session you have to idea like how we can get that free subscription and also we have many many things uh normal deployment like normal web app and API asor function we have deployed in our aor so many many things you can learn from here so let's start so first of first what I do simply let me create a new application for the scratch I'll show you so create a new application so you can create any we application and API application whatever you want you can just create it but as of now I will use over here net core web API so next and let me just set it for example it is a on aure so let me set this name as a project name let me create next and go back yeah just change uh it is just changing my folder directory location so is is it is it up to you yes you can keep it and I'll as of now I'll just remove that https over here but yeah in upcoming session we'll cover this https one but yeah as of now it is net 8 and everything is a default one right and keep create so once you create you will see this is a normally your B app or API applications right which is provide the default template so if you run this application you are able to see uh default endpoint is a better forecast so see this is a simple better forecast to make sure it is working perfectly right so yeah now it's working perfectly what I need to do simply close that right and here first I will add you know uh the docker uh Docker Docker files and Docker support things right so how we can do that many session actually I have created for that how we can add that Docker contes things and all so what I you need to do you have just create a right click on the project go to add and click the docker support and choose here like Target framework as a Linux and you know container build on the docker file or net SD so as of now I will use that you know whatever default like Docker file and Linux and okay once you okay you are able to see this is a newly file actually has been created over here right which is a Docker and uh once you create this doer you able to see also the starting starting also uh starting uh setup also provided using the docker you can run this using the docker right so what I need to do simply I'll show you first I will run and show you like inside the local local setup how is the looks likees inside the working in a local Docker so once you run using the docker profile see it is running in our local local doer things which we have already installed right so if I show you see this is my doer things if you go to the container and this is that container actually see single file and this is running on that Port two 37 and all right 3 2770 so this guy actually running so that is perfectly fine now how we can deploy this Docker container in our Azor part right so that is important so what I need to do first I have to go to my you know Azor login so go to your uh Azor portal and go to that home first and then go to home and here uh there's a two way actually so uh first of I'll just use that visual studio and then I will use the C command so first I need to actually create a Azure you know uh app registry I know Docker container registry we have to create so let me search for here so yeah uh looking for for this container registry so this is that one you have to look for this container registry first you have to just create you know container registry so click on that once you over here uh if you first time come here definitely you don't have anything but yeah you have to just create first your registry over here click that so here uh whatever your know subscription and all you can just choose it over here and name it whatever name you want so it is a single container uh deployment on aure so you can make it your registry name so I just make it whatever my registry name so this will be actually collapse with this you know uh this guy if you clearly see so this guy your your as your single container with DOT do aor ioc so this actually required I'll show you how we can use that so once you're done choose whatever your place right so I'll just use it it is a default one whatever we have and then choose that plan so I'll just use the EXT standard one and review and create and create now once it's done uh deployment complete you know just create it done go to click that go to Resource and you are able to see here your uh registry container registry has been created but as of now we don't have nothing if you go to repository so in this depository section actually whatever your container will create it it will populate over here right so as of now we don't have anything so what you need to do actually first uh one setting actually have to do taken care in this content registry which is going inside to uh that access keys so once you click that access key now you are able to see over here regist name and login server right so this is our login server this is a register name but actually if you trying to authenticate and you want to push something in out outside of that aor so what you need to do you have to record some credentials right so if you click that guy you know admin user so it will just generating your you know password and you know these things so based on this actually you can just this is a username and this is a password so based on this username and password you can authenticate and you can push that things so these things you have to complete so this is done now go back to your visual studio right uh go to your Visual Studio over here and and one more thing actually we have we can create it but yeah uh first of all uh we have to push uh our image actually in our container we have to push in our uh aor right so what I need to do right click on that there's actually uh many way uh you can just together uh you can just you can just deploy together like application as well as that your content but I'll show you uh everything from the you know step by step like so that you can understand clearly like what is happening actually so first I will just push that container right so how we can push the container right click go to uh right click right click on that publish and click that see there's a many option right so if you want to complete your application you can use this guy or if you want to just single registry you have to push so you can use that this gu so what I will do both way will check but as of now first I will use this Docker container as his click that and here what I will do see there's a three option again like if you want to push dockerhub as your registry or you know other things so but as of now we will use this guy so let me choose this guy next and here definitely once you're login on if you also if you authenticate uh in your visual studio so it will populate and it will show you whatever your things right so see this newly we have to create right this guy so this one we have to you have to choose this guy next and choose that dock desktop finish close so once you done now see it is profile has been created but yeah still not deployed so what you need to do simply click on this publish button once you click that publish it will start to create your container and push that container registry so see everything actually just uh doing itself right first they actually try to log in and then once your login complete they will try to push that uh create that image and push there now see finally it is uh creating this name and Si and also you can see over here and successfully push your Docker image with the latest tag latest version right so now uh go back to your here and here uh container registry go to that your repository and refresh once you refresh now you can see over here your uh depository has been created for the docker container right now once your know uh container has been created right what I need to do this container actually we have to associate in our app service now go back to your here home in the portal and just create a app service click on that create a new web app service right so create on the new B up so create on B up and here what you need to do let me let me select the resource Group right and then here we have to specify the name of a web name so BB API with single container right whatever name you want you can just put it yeah so here that options like see there's a publish options right so in this publish options there is a three options what I will do I have to use this guy because we have to trying to deploy using the container right so we have to use this guy once you use this guy so actually they uh suggesting okay whatever the operating system so I will use this you know uh this Linux because Linux is uh sufficient and then whatever reason you want to choose you can choose it as of now uh it it is my sand work subscription right so I have to choose you know different different uh reason for here neither it will give that some uh exception so yeah I will use that as of now here but yeah whatever things you want to use that you can use it and I will use that uh three as of now and then next and now here the main important part that container section if you see here that know scale side car support and then image source is you know whatever quick start and Docker Hub and all so if we have an a single container right single container so this time we use this guy as your container registry and here that options again this two options right so it is a single and multiple so yeah in upcoming session we'll use that uh multiple one uh with the docker compose and now this time you use the single once you choose this guy see whatever repository registry you have just created right and whatever image do you have right so automatically will populate over here see this is my registry name and this is my image name and this is the latest tag over here and once it is done right so let me review right and yeah finally it's a review page so you can just review whatever you have done so as of now I have done everything and once I just create it will take some time to create and now it's deployment in progress so we have to wait to deployment completed yeah see deployment successed succeed and click that go to Resource so now uh your app is ready right so once I click see this is your domain name right this is a default domain name but you can change your custom domain as well but yeah this is your default domain name once you click this guy yeah now see it is perfectly running your application but yeah this is our web API right so then in B API there is no startup page so that's why there is a nothing over here but yeah we can uh forcefully ask actually we we can ask to the request of that whatever the end point right so whatever our end points you can check it over here now we have only one endpoint we forecast Endo right so copy this we forecast endpoint and go back to here and simply just pass as the URL right here WEA forecast now see you are able to see your data over here so don't bu about that we'll add that swager UI as well so that we can see all the end points whatever we have right so let me change that right so what I need to do go back to your solution so this is your solution here if you go to to that program CS P here just only you know soer will apply only the deployment environment but see by default we deploy uh it is not deployment actually it is a production uh deployment so that's why it is not allow over here so what I need to do simply just copy and paste it on down and just commented this section so that every deployment right whether whether is a uh is a deployment or you know development or or some other OT and all everything every every deployment you will get that swager UI as well so this is that one now I will show you one more thing actually see last time we just deployed using that you know visual studio right we just deploy our registry using the visual studio right so this time we will deploy our image uh using that asor c so that also you have to know right so what you need to do first of all you have to in install Azor CLI right so uh you can just download over here right uh I'll just show you where you can just download so asor CLI download you can just search as your CLI download and here install as your CLI on for window and Mac whatever you want you can just install over here right like that you can just install here so I already installed so what I need to do uh you can just check it verify once you installed so open any command prompt right and in this command pront you can just check AZ right once you AZ so actually as CL once you install so it will actually see if it is install so you will able to see this kind of uh things over here and also it's we can check that version as well so AZ version right so once you hit this command it will show that okay this is that your version right so like that actually you can verify so once you have a asor CLI what what you need to do simply go back to your Sol uh project right and here go open your produ solution Explorer here and uh go back to one more step like see this is your root directory right inside this root directory there's a solution folder right and inside you have uh Docker file so what you need to do you come back to here uh this directory we is actually solution and here go to that Command right open any command and specify your project directory so this is your project directory and here what I need to do I simply pass one uh command where I can just push uh our image to our registry directly using Azor CLI that I I want to show you over here so where is that command let me grab that command because it is a very weak command so what I need to do simply I just zoom in for you little bit right and here so first you have to just use that AZ right and then ACR ACR then build and then build image so you have to specify that image what is that image you want to build so I want to image and specify the image attribute and then specify the name and what would the name so let me get that name from that whatever we have just created over here right so go to that again container registry and if you go to here so this is your registry name but if you check in the repository this is your image name right in this repository see this is your image name so what I need to do simply I need to copy let me copy this guy and go back to your command prompt and just simply paste it over here and this is one thing you have to done then next thing you have to specify here what is that reposit registry right so just make it uh attribute at a registry so registry and where you can get that registry name so again go back to here and uh yeah this is your registry name right so copy this guy and uh you have to specify you know registry along with your uh complete name right so where you can get it uh this is your regist name but yeah you can get it from here you can go to that access keys right and this is your login server right so this is your complete registry name so copy this guy right complete this guy um just zooming for you yeah this guy with this uh regist name along with your uh domain name like asor C IO right so copy this guy go back to your command again and mention over there right so this is done right again it's complete and then registry also done once you registry done now you have to specify here is your Docker file right so that you can check here like see where is your Docker file your Docker file this is a main root directory but in this directory we have another folder and in this folder we have a Docker file right so there's a two actually you can just get it from here to back it over here because doer file should not uh should not keep in this project level right that should be should keep in our solution level so you can keep it outside over here but yeah as of now it's fine uh so what you need to do simply go back to again command prompt right here uh mention your path name so what is my path name uh like that this is my path name this is my folder name right and uh here this is my folder name and then Docker file inside this Docker file we have so let me set it the file so where is my file my file is this folder and then slash uh what is my file name is a Docker file right and then space dot this is important actually see I specify dot right so you just specify the dot because it will complete the docker file command actually they will create a image for this using this period dot right so this is actually com complete Command which will actually push your image to your uh registry container registry in Azor right so once you hit enter so it will start yeah one more thing actually I forget to here so see uh you have to try to login First so if you're trying to use as your CLI command to push your registry so you have to try to login First so what you need to do simply try to log in your here so what I can do simple AZ uh login so you can pass this Command right and once you as at login hit enter it will asking actually uh this guy so whatever your login you can just add it so my login is this guy so this is my username and hit next now asking password so my secret password sign in now see it is logged successfully over here right so once you loog Lo in successfully over here you will go back here now see you will get this options like okay you are successfully log in and if you're not logged in successfully definitely it will not appearing like such kind of things okay so once you login right uh in your main as login so what you need to do you have to login with this you know Azo registry right so again you have to try to R another login uh so for that you have to uh require that username and password right so here you will you will get that username and password see this is again go to your uh registry container registry and go to your uh registry one right so this is our registry and if you go back to you know access keys right so here you will get actually we allowed that admin user right so this is our you know uh login user right and this is our password right so we have to authenticate like that right so go back to here right what I need to do simply AZ ACR and login right and here your registry name so you can just pass your registry name for example this is my registry name right username so go back here pass it this guy and that hit enter okay now I miss actually some one command see it is asking clearly you have to use ACL login then n and then my registry name right so I just missed that so what I need to do simply go back to here login and then use and hit enter now see login succeed because see they don't ask me that password why because I already login in our uh Azor login right so that's why they not asking but yeah if you want to uh you don't want to login this in know main aor login so that time definitely if you try to login definitely they ask the password and they want to the credential and all right so but yeah as of now we are good we already login like this way so you can use this way also instead of creating complex way so now we can use our push Command right so let me add that push command again so this is my push Command right we have just create a a build and images and registry and file where is my file and that hit enter now this time we are good to go to create our image and push to our registry now see it is successfully right you can get that message this successfully and if I go back to here and go back to that go back to our app right so where is my app go to here uh app Service uh this is my app right so go to my app and again it will take some time actually not more than but yeah at least 1 minute or 2 minute actually to reflect whatever New Image actually appearing right so let me check uh let me open again one more more time and this time just make sure uh just use that Swagger right swager hit that enter so yeah it will take some time to reflect so we have to wait now see after some time actually it's reflecting because it take some time actually whatever the new image uh get pushed so they take some time so most probably two or 3 minute Max right so yeah after that you can see once I add the Swagger it is automatically pop over here because this is a new changes we have done right and here we can easily get our uh changes over here right so this is done right uh this is actually both way actually we tried like direct Visual Studio we can push that things and also we can uh push the our cont container using that CLI so both way you have to know that so that's all for this session and thank you have a nice day and don't forget to like subscribe and share
Info
Channel: DotNet Real world example
Views: 615
Rating: undefined out of 5
Keywords: docker containers, azure, .net core, web api, deployment, tutorial, .net 8, programming, development, cloud computing, containers, .net 8 and azureacr, cloud, devops, microservices, docker container, .net core web api, container registry, ACR, Azure CLI, Azure PowerShell, How to Deploy Docker Containers, Docker Containers on Azure, Deploy Docker Containers on Azure with .NET Core Web API, Deploy .NET Core Web API in Containers, How to Deploy .NET Core Web AP, Azure & Docker
Id: rBnIS2QXESE
Channel Id: undefined
Length: 25min 56sec (1556 seconds)
Published: Wed Apr 10 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.