In this demonstration,
we'll combine our new skills with Windows Server containers with Azure,
and I'm going to use the Azure command line interface or the
Azure cross‑platform CLI as it's called.
This is just one of several toolsets available in Azure.
We've got Azure PowerShell, we've got the underlying ARM REST API.
However,
I think you'll find that when you're working with Docker containers in Azure,
the Microsoft engineering teams appear to have a
strong preference for Azure CLI.
I also mentioned that you may very well see some Azure CLI
code on your AZ‑800 and/or AZ‑801 exam, so this is relevant.
You want to make sure that you install the Azure CLI on your Windows,
macOS, or Linux computer.
You can even install the Azure CLI on your Windows
subsystem for Linux or WSL2 on your Windows 10,
Windows 11 box.
I give you a link to this page in the exercise files.
And I mentioned in the previous demo and VS Code,
you'll want to make sure that you have the Azure CLI tools extension installed,
and when you do that, you then can create files with the AZCLI extension,
and we'll see down in the lower right the language
mode is set to Azure CLI scrapbook.
So again, you get code complete, IntelliSense, all of that good stuff.
Now what I've done behind the scenes is I've used the docker tag
command to rename my mcr.microsoft.com/windows/nanoserver ltsc2022
image to something a bit more reasonable.
It's now called tim/nano:v1,
and I'm going to push that image to a new Azure Container
Registry that we're going to build.
Now, of course,
we can deploy the registry in the Azure portal as I previously mentioned,
but I want to just spend some time with Azure CLI to make sure that
you're confident when you see it on your exams.
So we need to interactively log into Azure,
so I'm going to do a az login,
and that will spawn a browser tab where we can sign in with our Azure account,
and then we can come back and verify our context in the Azure CLI momentarily.
I have multiple subscriptions,
and I want to make sure that we're connected to the correct one.
I'm going to be looking in the JSON output for isDefault true.
Yeah, and it looks like it's set me on the wrong subscription.
So what I'm going to do is az account set,
and again, this is the Azure CLI extension coming to the rescue.
I'm going to do a subscription Microsoft Azure
Sponsorship is the name of my subscription,
and I'm going to right‑click and run that in the terminal.
And now what I can do just as a quick check,
az account list output table and make sure that my
sponsorship subscription is set up correctly.
It is.
Another thing I'm going to do is actually run az configure.
This is something I recommend you do.
Do you wish to change your settings?
Y for yes.
I don't like the JSON output so I'm going to change the
default output format to three here, which is table human‑readable.
I don't want to do logging.
No.
I'm not going to do data collection.
I'll use the default time to live, and do a clear screen.
Okay, let's continue.
So the code has us doing this from soup to nuts.
I borrowed a lot of this code from the Microsoft docs here.
You'll see that the way the syntax works for Azure CLI is
very similar to how the Docker CLI works,
az and then our context and then our command.
So az group is working with resource groups in our subscription.
Then we have az acr for Azure Container Registry.
I'm going to create a new container registry with the basic sku.
Now the thing to keep in mind is that you can pass in
a whole bunch of other parameters, this is just very generic and basic.
There are a lot of configuration options as you
would expect for any Azure service.
Next,
we'll want to sign into the registry using our
appropriate Active Directory credential.
I'm going to do an az acr login here.
Login succeeded.
Okay.
And now we can, again, switch over into Docker mode,
and this example has us pulling down the hello‑world
image from the Docker gallery.
I can do that for grins.
Hello‑world image is just a console application that says hello world.
Whoops!
It bombed out because hello‑world is actually a Linux image,
and we've got this Hyper‑V system setup for Windows containers.
No big deal because I already have my server Nano image that I showed you.
Here, on Line 15, I'm going to retag my tim/nano:v1 image to twaz800acr.
Now this is just to let me know that it's going to be housed
up in Azure in the container registry, and the tag is going to be nano:v1.
So let me right‑click, tag that image,
and we can verify that doing a docker images.
We now can see down at the bottom, we still have our tim/nano:v1.
So notice that tag doesn't destroy anything.
It just creates another image reference here,
another image,
and we can see our size difference between the Nano Server that's about
300 MB and the server core IIS image that's almost 6 GB.
Again, 6 GB is a lot slimmer than any virtual machine out there,
that's for sure.
These are some of the value propositions,
as I've mentioned several times, of Docker.
And now,
we can use docker push to upload that image to the Azure Container Registry.
Now this is going to be an authenticated operation because,
by definition, the Azure Container Registry is not a public repo.
Okay, well that was really, really fast,
faster than I thought the upload would take.
So let me switch on over to my browser,
and let's sign into the Azure portal here.
We'll open the global search, and we'll go to Container registries where,
no surprise, we see our twaz800acr container registry,
and if I come down under Services, Repositories,
we can see our nano image nano v1.
Now if I come back to VS Code,
we can very easily start a new instance of that image by
using docker run as you can see right here,
and notice that when we docker run,
we're pulling that image from the cloud down to our
local system and then starting it.
However,
I want to end this demo by staying in Azure and showing you how we can
integrate our Docker registry with the Azure Container Instance,
or ACI service.
Let's go to Create container instances.
I'm going to create this instance in my az800‑rg resource group,
and I'm going to call this nano.
It'll run in the East US.
The image source can either be one of these starter images
that Azure has natively in the dropdown,
Azure Container Registry, Docker Hub, or another registry.
I'm going to choose Azure Container Registry,
and notice it says the admin user must first be enabled.
Well, I've actually done that.
I'm surprised it hasn't picked up the change.
We don't have the time or the scope to go into ACR security,
but the bottom line is if you come down here in your
container registry to Access Keys,
the admin user is generally not a great idea because it's a shared
credential where we have a username and one or two of these passwords
that your developers or your scripts or your processes can reference as
a way to sign into your registry.
It's recommended that you use Azure AD authentication and authorization in here,
but unfortunately the ACI looks like it has a hard dependency on the admin user.
But let's try this again, and hopefully, the second time is the charm.
Let's choose the resource group, we'll choose the container name,
yeah, there we go.
Azure Container Registry,
it already populates because the container instance dialog
sees that there is only one image available.
We can change the size of the underlying host by giving
the host more or less CPU and memory.
For networking, this is an important point right here,
especially for something like a Nano container where we
might want to establish a command line session to it or
interact with it with sensitive data.
Public is going to do a public IP address for the container instance,
but there is a private option to where you can embed your container
into the privacy of a virtual network in Azure,
you see what I mean, and then we can have port mappings.
Now, I kind of realize in retrospect I made a mistake,
I should have grabbed the IIS image and pushed that up into Azure
so it'll actually run and show us something.
This nano doesn't have any web components on it so it's going to be
more difficult to interact with over the internet.
But you see that, you set up your networking,
and then under Advanced, we can set or pass environment variables,
we can set a non‑default entry point.
In Azure, we've got our taxonomic tags for logical resource organization,
and then we can spin up our instance, and then depending upon how it's set up,
we can connect to it, interact with it, destroy it, all using Azure Resource Manager tools.