Azure Container Instances Tutorial | Serverless containers in cloud

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you are using containers and just starting with Azure you should definitely check out Azure container instances this is Adam and today I will give you a brief introduction on how can you use Azure to host your containers in just couple of minutes stay tuned before we start with what container instances are let's talk about what are containers containers is a standardized unit of software what this means it's just a package software that should be able to run reliably between each another computing environment so that sounds very similar to what virtual machines are so let's talk about first what is the difference between virtual machines and containers so in case of virtual machines there's always a host the host is created from the infrastructure on top of which there's a hyp... hypervisor running this hypervisor is responsible for hosting virtual machines and managing them so there's always a virtual machine on which you always have something called guest operating system so therefore you need to virtualize an entire operating system for you to be able to host your application and you need to do that again for every single application when it comes to containers you also have a host that hosts again has infrastructure but what's difference here is first of all you have a host operating system on top of which there's something called run time this run time is responsible for hosting and managing containers but what is good here is that from here onwards you can just host containers you no longer need that guest operating system for each application and each container therefore releasing a lot of unnecessary resources and as such allowing you to host more containers and more applications so the main differences here are first of all there's less development overhead so your developers don't need to create container... uhm they don't need to create those images for virtual machines which takes a lot of time creating containers take just minutes and if you know and you have priority prepare scripts in just couple of seconds and as you've seen there's no guest operating systems so there's much less resources consumed which also means since there's no guest operating system loaded into the container the file itself is in much smaller size it's from hundreds of megabytes down to 20 30 megabytes of size since the small size is there and the less consumption is required that means they also are starting up faster you can get your containers running in just seconds and because you're not running that OS this against means there's much less updates that you need to do therefore there's a reduced and simplified updating process that you need to implement for managing your application so container instances is a service in Azure and most simple service for running containers without managing any instructure and in just couple of minutes allowing you to start your own containers and host them in Azure so first of all how does it work always there's a virtual machine underneath it but this virtual machine is organized into something called container group container group is just a grouping of multiple containers where you can host multiple applications so you can have multiple applications each can have its own share if it needs a persistent storage or it might not need that so it's an optional thing but each application can also expose a port like port 80 for five thousand and if you need you can expose that port further to allow for public connectivity which allows you to get a public IP and a public DNS name for your container so a public connectivity can be established this way... this way you can actually host your web applications using containers in Azure in just couple of so what are the key benefits first of all fast startup time AC I can start up your containers in just few seconds this time of course depends on how big the image that you created this but usually it's just couple of seconds you can get that public IP and DNS name that we are talking about if you need the public connectivity there are multiple custom sizes of virtual machine that you can spin up to hold your container group so this is the custom sizes and again all the containers can be hosted on both Windows and Linux virtual machines which allows you for great flexibility Linux would be recommended way to start off but if you have that very custom very specific need there's always a Windows container you can get persistent storage we already mentioned that you can do that through file sure but there are a couple more options available and lastly one of the key benefits of ACI is that you can actually deploy your containers within virtual virtual network this allows you to connect to those firewall protected and on-premises resources so we can actually go to demos now I have three demos prepared for you the simple web application in which I will deploy out of the box ready container with very small node.js web application second of all the second demo I will change that image and create a custom image with my own node.js application and I will deploy this to Azure container instances and lastly I will create a scenario where I will use container with a batch job that will calculate some words for me this will be an example of one daily small job a very often scenario in our real-life applications so let's go into the portal so in the portal now we can go and start creating our container instances to do so we click on this + to create resource we type container instance we hit create and as always we need to provide the resource group I always have one created for the demo and I need to provide a container name so this will be my container group name actually same just gonna give it a name AM demo 4 the name doesn't matter but it's fine I'm gonna give it a region and North Europe is always the closest data center to me so I'm just gonna leave it my image type is public this is a name sorry this is where the image is currently located I will be using a public container registry from Microsoft to get a docker image so what I will do I will copy paste the URL to do this image so this is Microsoft content registry at microsoft.com from the azure docs and this is ACI hello world latest version so this is the container containing node.js application with simple hello world and this container registry is public there for engines leaving this as public next is OS type I'm just gonna leave Linux and next I'm just gonna leave 1 vcore and one and a half gigabytes of memory if you go to the next tabs on the networking you see that we have exposed port of 80 over tcp and we're gonna get public dns public IP but if you want public dns we can also get that so let's type amdemo4 this is currently available so I'm just gonna review looks everything fine and I'm gonna hit create so I'm just gonna wait this takes about a minute or two the deployment is completes I can go to my resource and this is how it looks in the portal there's not a lot actually that you get because as I said this is most simple service so first of all you have that IP address that we're talking about so you can copy paste that into the browser and see our simple web application running on Azure docker so and a second one you can also use DNS instead of the IP and you get the same result that was super simple and super easy to run so this is the container instances service the current status of this group is running within that group you can review what kind of containers are currently running so this is our amdemo4 container it's running from the image mcr aci hello world the current state of that container is running that's the rest that's the start time and the restart count in case it's gonna be failing there's gonna be multiple restart counts here you can review the logs for your container you can review properties of your container you can check the internal logs of the server you can even connect to it to the bash and run some commands if you need one of the coolest things about container instances that it also allows connectivity through manage identity but it's currently in preview so I'm not gonna cover that today so that was the demo one it was as simple as this just creating the container instances service and passing the URL of the public container registry so let's do second demo in which we're gonna create a custom image to create a custom image we need a place to work on the on that image so what I'm gonna do for today I'm actually gonna use cloud shell cloud shell is amazing to do this kind of stuff especially if you're learning I will have a separate video on cloud shell in the future but for now let's just follow this through first of all we need to mount that storage in order to work with cloud shell because we'll need a storage where we are gonna work on our files so I'm gonna hit create storage and you might actually expect to get this error because what it will try is will try to create a storage in this kind of resource group I don't have that resource group currently available and I don't have permission to do so so if you encounter this error just click Advanced Options and select use existing resource group and creates cloud storage here so I'm gonna call it amstore01 and I'm gonna do the same fall for the file share I'm gonna hit create storage after about 45 seconds my storage container was created and I'm able to use cloud shell so in the cloud shall what I will do right now is I'm gonna clone the git repository of the container we just deployed the hello world ACI demo so I'm gonna paste in the URL get clone so I'm cloning the repository I will actually open it so let's see what do we have we have a folder ACI hello world let's go into that folder one of the cool thing about cloud shell is that you can open a very small editor that looks very similarly to Visual Studio code by typing code in here you get that editor and you can review it let's maybe change a font size a little bit bigger actually sorry that changes only the cloud shell so in here you can actually navigate through those files you can do a lot of stuff but what I want to show you is first of all the folder structure you have an app folder with a new within which you contain your node.js application so this is the index file that you've seen welcome to our container instances and the image so what I will do I will actually replace the default image and type custom images just to prove a very small demo of nodejs what else do you have in this folder is index.js file this is the node is starting file which will basically initialize your web container and start with index.html file you have of course the packages definition for node.js as well and a docker file so this is a docker container and it basically states that we're running node application from which folder what is the working directory what to run and install all the packages and do all that kind of stuff but since this is not the demo about the docker itself I'm gonna leave it here so since we already did our change we can close editor you can do it by hitting close editor here or hitting ctrl Q and running another comment so what we will need right now in order to run this comment we will need to actually host our custom image somewhere to do so we need something called container registry I will file very briefly show your container registry today because this is not that training about container registry at all so I will just briefly create it to create it we again hit creed resource type container registry container registry is Azure service for hosting containers for more than just other container instances you can use it also with kubernetes service service fabric and many other services so I'm gonna install a name I'm gonna call it a4e ACR 4 Azure container registry I'm gonna select a resource group again north Europe everywhere everything that I host is theirs I just want to be close to possible I'm gonna hit enable for the admin user because this is a private repository I'm just gonna need an admin user to connect to it I'm gonna pick basic tier and hit create so right now we are deploying a service which will allow us to build a docker container and host it since that's finished very quickly we already have a4e ACR container registry so let's go back to our code since we already have our code and we changed our application to our liking we can build the container to do so we can use a comment from the azure CLI our azure container registry built from the image called demo custom image demo version 2 we can actually change that version if we want this can be a version 1 to the registry called in our case that was a4e ACR and from the file docker file so let's run this comand in 29 seconds we are able to send the entire docker code build it and store it on Azure container registry if we go back to container registry in two repositories you will see our container image stored so if we have that stored right now we can actually click on it see that our version 1 is there and there's our URL to the container so let's close this comment shell we no longer need it let's create new resource type container instance hit create and in this demo I'm gonna create a new container instance that's gonna be AM demo 5 I'm gonna also host it in north Europe this time it's an image type private so I'm just gonna paste that image sorry that's not the one let's copy this comment here so the image name is this full URL to your container registry and the name of the container since this is not a public registry we need to hit private go back to our container registry go to access keys and first of all copy the login server paste it here you need also the username to connect to so let's copy the username and lastly we need a password so let's copy the password let's leave as Linux and also the size as default so let's review and create and hit run and we're done so we can actually go to the resource copy our IP and open it in a browser and again this was our custom-built image and it just took a couple of minutes so let's go for the very last demo for today let's open a resource group and let's create the very last container instance let's hit create and for the very last demo I'm gonna call it am demo 6 I'm gonna provide it with public image from Microsoft and this one is gonna be ACI word count this image contains a code that does a batch job based on the parameters that we specify this job will go through the Shakespeare novel and count how many words of length x that is also parameter is within the novel and return the most commonly used ones so let's see how this works so we provide this image name but what we also need to do we need to go to networking but actually to Advanced tab in Advanced tab you are allowed to specify environment variables this batch job requires two a number of words in which case we're gonna specify 8 and the length what is the minimum length of the words you're looking for I'm gonna specify 6 so what the script will do now as a batch job once it's running it will find them 8 most common words in entire novel that has minimal length of 6 characters so let's review that and let's hit run so the provisioning finished we can go to the resource check our status is succeeded this is different than the last time that we had running that means all the containers within this container group finished their jobs so if you go to containers you see that our container has a state of terminated you can review their logs but what is most important besides those events here is the log itself within the log you have the output of your batch job so have we our eight words with minimum length of 6 and how many occurrences of those words were in the Hamlet Shakespeare novel so in this case we were able to run a batch job using containers and we'll just paid for the execution time which is very cost effective this is why container instances are one of the serverless options for running containers in Azure as of today as you see this allows you to cover all kind of scenarios from the ETL through batch jobs and even web hosting scenarios in Azure using a Azure container instances so let's recap first of all we did three demos one public custom image web application from Microsoft second of all we created our own image and hosted in on Azure container instances and third we use custom images to create a batch jobs that we executed on demand this is how powerful these service is and how can you use it in real scenarios that's it for today if you liked the video hit thumbs up if you really liked the video leave a comment and subscribe if you want to see more and see you next time you
Info
Channel: Adam Marczak - Azure for Everyone
Views: 141,426
Rating: undefined out of 5
Keywords: Azure, ACI, Containers, Docker, Container Instances, Beginners, tutorial, ACS
Id: jAWLQFi4USk
Channel Id: undefined
Length: 21min 26sec (1286 seconds)
Published: Mon Sep 16 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.