When you work with Azure every day,
you're often thinking of ways to make your work efficient and quick.
Woking with the Azure CLI is one of those ways that you can cut minutes from a
task and have time for Lego. I mean more cloud. Yes.
The Azure command line interface, referred to as the Azure CLI,
is a tool for creating and managing Azure resources.
It is all text-based with no graphical interface and is developed with an
emphasis on efficiency. When you work with Azure every day,
the CLI can save you a lot of time compared to using say the portal.
Creating a resource in the portal involves a wizard,
which has many button clicks, drop downs, fields,
pages of information to fill in and more. It takes several minutes to complete.
And if you create resources often enough, those minutes become hours,
days, and weeks and months, you know. Using the CLI instead,
you can use a single command, perhaps two,
to create or manage the resource. It takes seconds. Maybe a minute.
In this video,
I'll show you how to get started with the Azure CLI by showing you how to
execute some basic CLI commands,
both on desktop and in what's called the Cloud Shell.
But before get into that, first, let's learn how to install it.
To install the Azure CLI on your local machine,
you use the Microsoft Docs page for the Azure CLI install.
Now the link to that is in the resources for this particular video. Now,
in this case, I have the Azure CLI for Windows.
And if you scroll down a little bit here,
there is a current release of the Azure CLI. If I click on that,
it will download a pretty stock standard MSI install file,
like so.
I can open it and it's just a completely standard
install experience. Like we are used to. Click next, next, next,
et cetera.
Now I have already installed it on this machine so I can choose to repair it.
But if you haven't,
you can install it and then we'll be up and running with the Azure CLI.
So let me show you that.
And then we just have a standard windows command prompt here,
and now the Azure CLI commands will work in here.
So I could do an AZ login command,
which is the command to login to the Azure CLI.
That will open up a sign-in form here.
I'm now logged into my Azure account and I can now use the Azure CLI.
Another way to use the Azure CLI is through the what's called a Cloud Shell.
If you go to shell.azure.com, it'll take you through the login process again,
if you haven't logged in already, and you'll get to this screen here.
Where you have to choose bash or PowerShell.
Now bash is just like a Windows command prompt.
So I'm going to use that in order to use the Azure CLI.
So this is a complete online experience. It's all in the browser.
So the first thing you need to do is to attach a storage account,
or a storage device or service to your Cloud Shell,
because it has to store all the metadata and certain files you might upload,
it has to store that somewhere. So in this case, I'm going to create a storage,
because we don't have any storage. And once the storage is created,
it'll just create it for you by the way, you don't have any choice on naming,
et cetera. It will create the storage.
And then we now logging into the bash shell of the Cloud Shell with a bash
experience of the Cloud Shell. And that will allow us to use the Azure CLI.
So it says here we can type AZ to use Azure CLI so we can type AZ.
And that'll give me all of the different commands that are available for the
Azure CLI. So that is another way of using the Azure CLIs.
So there's the desktop experience,
where you install the CLI and use a command prompt. There's the Cloud Shell,
which is a complete experience in the browser.
And then there's actually another way to use the Cloud Shell is,
if you're in the portal up here,
you can click the little terminal button here that also says Cloud Shell.
And it'll open up sort of half a screen,
where you can adjust how much you want this to fill up.
And it is also the Cloud Shell experience,
but you have it sort of inside the portal.
And that could be useful if you are learning how to use the Cloud Shell or the
Azure CLI,
you can see what happens in the portal at the same time as you create and manage
resources. So those are three ways of using the Azure CLI.
So now let's move on to a bit more theory.
There are many ways to interact with Azure and manage resources.
The CLI is just one of them. For this reason,
there needs to be a service to manage all of the requests for various tools,
and then forward those requests to Azure.
Otherwise Azure would have to implement a new set of features every
time a new tool was created.
This management layer is called the Azure Resource Manager and all tools,
without exception, wanting to talk to Azure, have to go through it.
The Azure CLI is one of those tools. In other words,
the CLI talks to a software development kit, SDK,
that then talks to the Azure Resource Manager,
which then talks to the Azure resources.
This ensures a consistent management layer that also authenticates and
authorizes each request.
The portal is often used for troubleshooting and learning about new services,
but the CLI is mostly used for creating resources and
environments day-to-day.
If you create scripts of Azure CLI commands,
these can also be used to automate certain tasks and they can also be added to
source control tools, versioned, and peer reviewed.
Let's have a look at a couple of the commands that you can use with the Azure
CLIs. So, I'm in the Cloud Shell again,
that is probably the easiest shell to use because it's always available if you
have a computer with an internet connection.
So let's start with az account and then list,
which means we want to list all the accounts that are available to this
particular login. So you can see there's one there ACG TA, Lars Klint.
Another good tip is that you can always go --help.
So say I wanted to know something about VMs. I can go az vm --help,
and that'll give me all of the commands, I'll just scroll up a bit here,
all the commands available at that point for an az
vm command,
as in this says I can use az vm create.
Okay. So let's try that, az vm create.
And then I can do --help again,
and I get all of the available commands at that point of the
command. And then you can sort of build it up from there. So if I scroll up,
there's all up, VMs have a lot of commands. You can see this old sorts here,
you can put in --vmss: Name or ID of an existing virtual machine scale set,
et cetera, et cetera.
So --help is always available at any point on any command.
And that's really useful if you're kind of stuck and can't remember,
or you want to know what the options are for that particular point in a command.
Let me just go back down here to where we were.
So that's sort of just how you use the Azure CLI.
If you want to know more about all of the commands that are available,
how to use them. I have linked to a reference in the resources,
but there are also other videos in the ACG Fundamental series on how to
use specific things in the Azure CLI world. So I hope you enjoyed it.
All right, back to my face.
The Azure CLI is a tool that you will use all the time once you start working
with Azure every day.
It makes it more efficient to carry out those day-to-day tasks,
so there is more time for shenanigans, probably.
If you want to learn more about the Azure CLI and start using it for managing
resources,
check out some of the other ACG Fundamental episodes on that topic.
If you enjoyed this video, give it a thumbs up and consider subscribing to this channel
for everything cloud computing.
And all that's left to say is then: keep being awesome Cloud Gurus.