Practice Exams:

AZ-303 Microsoft Azure Architect Technologies – Implement Solutions for Apps (10-15%) Part 7

  1. Containers Setup Walkthrough

In order to follow the next lecture, you’re going to need docker installed on your computer. If you haven’t got docker already, it’s quite easy to get go to Docker. com, go to products and we want the Docker desktop, go ahead and download it for your environment. So once docker is installed, we can go and run it here. Created a shortcut on my taskbar and because of the kind of application it says, it actually runs in here in our task icons here. And we can see here that the desktop engine is starting up. So we just need to wait for that process to complete. And so once it starts up, we can then go ahead and start using it. Now actually docker is mainly used from the command prompt and we do everything through a series of docker commands.

So for example, if we simply tag Docker PS, we’ll actually see a list of running containers which as you can see at the minute, there isn’t any. Now normally you would create an image by pulling one from the marketplace and then altering it. You could do it all from the command line, but actually we’re going to do it from a command prompt. Now rather than start from scratch, what I’m going to do is pull down a pre created image and website to better test the functionality. So the first thing I want to do is I’m going to open this folder up in Visual Studio code. Now you can actually use any text editor and you’ll see why I just prefer Visual Studio code, especially with the docker extension installed because it makes things a little bit easier and nice to use.

So I’m just going to go and open a folder. Going to open our bulletin board here. And then we’ve got our bulletin board app here. Actually I’m going to navigate right down to that folder I think. So in here we’ve got basically a JavaScript application. We’re not going to worry about too much about what that is. The important thing we want here is our docker file. And you may recognize this. This is from the earlier lecture where we were working through what a docker file looks like. So again, just to quickly run through, what we’re going to do is we’re going to pull this image from the community marketplace. So the image is called Node and the actual version is the current slim. We’re going to then change our working directly within that application.

We’re going to copy this package JSON from my development machine into that image and then we’re going to run an NPM install. Finally we’re going to expose port 88 and then we’ll issue an NPM command start. And then the last step will be to copy all the other files that we have here, which will basically copy this JavaScript application over to the server. Since we have our docker file, what we want to then do is in our command prompt we first want to build an image from that docker file. First, what I want to do is I’m going to command called Docker space, image space LS. So this is going to show us any images that we’ve currently got installed. Now, as this is a completely new installation, as we can see, we don’t have anything. So let’s go ahead and build one first.

So we have our docker application here. So what we want to do now is run docker image build. We’re going to tag it now. This is going to tag it locally. I’m going to call it bulletin Board P One. Then I need a full stop at the end there that tells it to do this in the current directory that I’m in at the moment. What that’s doing? First of all, it’s pulling our base image, which is node slim. And we can see this. It’s downloading this from the public docker registry.

You can see we then set our working directory. We’re copying package JSON. And then it’s going to run, or it did run before it went off screen the NPM install commands. And then finally it did the other commands here you can see we’ve got it successfully built and it’s been tagged as bulletin Board. Now need to make sure get that right because as you can see, I’ve spelled that wrong. If we now type docker Image LS, you can see first of all the base node image because that’s what it pulls down and it stores that locally. And then our own image that has been built on top of the node image. And the next thing we can do is just now we’ve got the image, we’re going to actually run a container from that image. Let’s do that. We’re going to docker container run publish.

I’m going to say 88,000, call on 80. 80. So what this says is that we’re going to run this application and we’re going to run port 80 on my computer that will redirect port 88, which is what we expose in here on that container. And that is how you can run websites within multiple images, but you will actually direct to them from your development machine from a different port that allows you to run multiple different containers. Going to run more commands here. So detach name. We’re going to give it a name. So I’m just going to call this bulletin board and then we need to tell it what image to use. So it’s going to be bulletin decorum v one and then press Enter.

So that’s now running. And if we go back and type Docker PS again, we can see now we’ve got a container running based on that image. It’s exposing port 8000 that’s redirecting to 88. And if we now go to our browser and we go to localhost call on 8000, this will actually now bring up the website that we’ve got running in our container.

So obviously we’re not doing anything with the zur. Now, this was just to get you up and running with running containers and how they work, because it’s important to understand how they run. Before we go on to the next few lectures, what I’m going to do now, though, before we just go on to that, is I’m going to remove that container that’s running. So I’m going to say docker container, remove rom false. And then we need to give it the name which we gave them, which is built inboard. Now, if we type docker PS again, we now have no longer no containers running. So in the next lecture, we’re going to take our image that we’ve created, we’re going to create a private registry in the Azure Portal, and then we’re going to push our image to that registry.

  1. Containers Build and Deployment Walkthrough

Hi and welcome back okay, let’s have a recap of what we’ve just done so we’ve used a docker file to define a new image that we’ve then built and so far we’ve done this in our local development we’ve then taken that image and using the Docker container command we’ve published it ie. Run it on our local development machine. In other words, we’ve taken that image and containerized it into a containerized app. So at the moment, that’s running on our local machine. And so what we want to do is built. Distribute that image so that it can be run anywhere. And the way we do that is through a container registry. There is a public container registry which is at Hub Docker. com. It’s sort of like GitHub for code, but this is for container images and Docker Hub contains lots of repositories that many organizations have created.

So for example, if you wanted a vanilla Linux image, there are a number of Linux images on here and to find them you can have a go to explore. And we can find official images, verified Publisher images, we can search on categories and so on. And as you can see off the bar, we’ve got an Oracle image, a MySQL image. And so on. If we go into the search bar and search for Node we will also see the Node image that our image was based upon. So if you remember in our image file we say from Node call on current slim. So if we look at that, that’s coming from the node image here, and if we go over to tags, we’ve got various different tags down here.

So if we filter the tags for current Hyphen slim, and that is the image that we have used. So the docker container registry is great, but the free one if you want to use it for free, then anything you put up there is public and searchable. So Azure provides its own container registry and that’s what we’ll go and create now so I’m going to create a resource and I want to create a container registry. We want the Microsoft Container Registry. So we’ll go and hit create and we’ll give it name. So we’ll call it Cloud Guru. We’ll create a new resource group for it and finally I’m going to enable admin user. Now by default, this is disabled. So enabling admin user is something that will allow it easier just for us while testing to be able to push and pull images from the container. So I’m just going to enable that for now. Next is the SKU. So I’m going to go for Standard that’s I’m going to go for Basic. And if we go to more information on pricing, you can see that the different options that we have.

So Basic you only get 10GB of storage to web hooks. If you want more storage, Standard will give you 100GB and Premium will give you 500GB. And obviously the price would go up. But for what we want, 10GB will be absolutely plenty for us at the moment. So we’re going to keep with Basic and click Create. So once that’s created, let’s go to the resource. And we can see here we’ve got 10GB available and we’ve not yet used any. If we look down the left hand side, we have repositories here and this is where our images will go. Now at the moment we don’t actually have any repositories because we’ve not pushed anything. So let’s go ahead and do that. Let’s go back to our command prompt. And we’re going to use the Azure CLI first of all, because what we need to do is sign in from our machine here through the CLI into the repository.

So I’m going to run AZ login and give it the name of our registrar, which in my case is Cloud Guru and hit Enter. So that should be a Zac R for Azure container registrar login. Let’s try that again. So this might happen on the first time you use it. So it’s saying I’m not authenticated at all. So I need to do an AZ login first instantly. If you’ve not got a Z, it’s because you’ve not installed the Azure CLI. Now that’s something we cover in one of the earlier lectures. So if you’ve not done that, go back, install that. Let’s just try this again. AZ Logging. That’s me logged into the Azure CLI.

So now once I’m logged in, I can go in and now log into the repository. And that is now authenticated me to the repository so that I can now start to upload images. So the first thing we need to do is let’s just remind ourselves what images we have. So we’ll do Docket Image LS to get a list of images. And we want to upload our bulletin bold image. Now at the moment it’s tagged with V One. Now what we need to do actually is we need to retag this or create another tag that will link it to our My Cloud Guru registry. So what I need to do is run Docker tag. I give it the actual repository I want to tag here, and then I give it the tag I want to have, which in this case is Cloud Guru Guru, which is the name of my repository. But now I need to give it what’s called the full FQDN, which is actually so it’s always your repository name. Cloud. Guru azure. Cr. IO. So I’m going to sayulletin call on v one.

If you’re not sure about what your actual URL is in your repository. In the overview page, you get your login server there. That’s the full URL of the login server that’s tags. Let’s just have a look at how our images again. So now you can see we’ve got an additional image there which is the Cloud Guru Azure Cr One. So now what we want to do is push that one. So we shoot the docker push cloud guru issue, call on V one and press Enter and that’s now pushed the image. So if we go back to our container registry and go to repositories, we will now see our new bulletin repository, which is the bulletin image. And we can see that we’ve got a single one there with a tag of V one.

And if you go through that, it basically shows us how we want to use it. So if you were to go to another computer now that didn’t have the image on, you would just issue that command to pull it down. And in fact, if we go back here, what we can say is if we take the ID, say docker image RM paste in the ID force so that is deleted and untanked the image. So if we now say docker image LS, so now we no longer have that image. So before we had the bulletin board image and now it’s completely gone because I’ve forced a removal. But if I now go back to here and copy that and then run that again, what that is now doing, it’s pulling down the images, pulled it down and now if I look, it’s pulled down the image from my repository. So now we have an image. What we might want to do is actually deploy a website from it. So if you go back to the home page and let’s create a resource now look, search for web, app for containers and click Create. So I’m going to use the same resource group that I’ve actually put my containers in. Let’s give it a name. So I’ll call this Guru container.

It’s a docker container, it’s based on Linux. I’ll choose my region. I’m going to change the plan size from the default premium and I’m just going to drop that down to a dev test and an F one which is free next. And now it’s asking me where I want to what image I want to deploy. So the default is it will do a quick start container, but I can change this to Azure Container Registry. It will find my registry and it will show me what images I have available and then which tags they have available. So that’s the one I have just published. We won’t install application insights not bought about tags. Let’s just go and create that now. Once that’s applied, let’s go to the resource and have a look. So here we go. We deployed it to an Azure website URL. So if we go ahead and click on that and this website will come up. So this is the one that when you saw it earlier, we run it locally and now we’re running it on the internet by publishing that image. If it takes a while for it to come up, just be patient.

That’s simply because we’ve put it on the free tier. If you put it on a more expensive tier, it would come up much quicker. Worth having a look around? Some of the options that are different between a containerized image web app versus a standard web app. The most obvious one is this container settings here. From here we get to see information about how we’ve deployed. So we can see we’ve come from a container registrar. You can also see that we can actually take images from the docker hub or another private registry. We can set up continuous deployments. So what would happen here is if we were to update this image and republish it, that would automatically redeploy this application. If that was set on, we also get to see the logs so we can see that when it started up, it’s pulled the image and it started pulling down and extracting the image here.

And then finally at the end we can see image pull successful and then we see the actual docker run command that it’s run, which then has started up the actual website. Everything else is very, very much the same. So for example, if you wanted to set out a scale out plan, you could start defining CPU statistics that would automatically make it spin up additional services. Again, because we’re on the free tier, it’s not allowing us to do that, but it was it’s exactly the same as when you use a standard web app. In the next lecture, we’ll look at a specific popular implementation of containers, which is an alternative to using web apps called Kubernetes.