Leon Welicki: Hello there and thank you very much for
joining us today in this new Azure Portal How-To Video.
Today, we learn how to inventory resources at scale
using the Azure Portal and the power of Azure Resource
Graph. And for that, we have Adam Abdelhamed, who’s
going to show us how to do that. So, thank you very much
for joining us, Adam.
Adam Abdelhamed: Thank you, Leon.
Yeah, so Azure has always given you a way to inventory
your resources for a single subscription. You go to Azure
Resource Manager, you can query and get that information.
But what if you have hundreds of subscriptions or
thousands and thousands of resources? Writing that script
is actually quite difficult just to even get a count of how
many subscriptions you have. So now, we have a new
service called Azure Resource Graph. And what this thing does
is it runs 24 hours a day and it indexes information about
all the resources you have across all your subscriptions
at scale. And then on top of it, it provides a KQL based
querying language on top of those resources.
We plan on replatting significant portions of the experience,
like our search and all of the lists of resources you see here
on top of Resource Graph. But today, we want to talk to
you about a tool we’ve built that lets you really dig in
and get to the meat of Azure Resource Graph and what
it can provide. So for that, we’re going to use the Resource
Graph Explorer tool, which I’ve got pinned to my favorites.
But you probably won’t have that, so you can go to search
and just type Resource Graph Explorer. There it is.
And what you’re going to see is a pretty familiar query
editing and execution experience that you’ll see in other
kind of database solutions. Now, let’s just start with the
most basic things—just counting my resources. Like I said
before, if I’ve got a lot of subscriptions, and I do, I have
about 37 subscriptions here, then writing that script would
be tough. But with Resource Graph, it’s as easy as this.
I’m going to type count. I’m going to run a query.
And there it is. I have over 17,000 resources. And this is
you’d expect. Why don’t I go ahead and save this query.
And I’ll just call it My count.
Leon: And one important note, when you say it’s
enforcing role-based access control, that means you’re
seeing only the resources that you have access to.
There are more resources on those subscriptions, but
you don’t have access, they will not come here, right?
Adam: That’s right.
Yeah. So, let me go ahead and pin that to my dashboard,
which is another cool thing we’ll show in a minute.
But the KQL query language is much more powerful
than that. Let’s say I want to get an understanding of the
different types of resources I have; well, that’s pretty
easy too. Summarize count=count by type.
And now, I can see all the different resource types that I
have and their counts. Even better, let’s say there’s lots
of them, let’s say I just want to get a sense of the top 10.
So, I’ll go ahead, and I’ll say order by count descending
take 10. So, these are the most frequent resources that
appear on my subscriptions. I could even come over to
the charts tab, and let’s take a look at this as a bar chart.
There we go, pretty cool. And I can pin that to my dashboard
as well.
So, this can get pretty sophisticated. On the left, you’ll
see a tree that shows all the different types of resources
that are in the subscriptions I have access to. And I can
unfold this and take a look at all the different specific types
that I can query on. Rather than doing that one by one, I’m
going to switch gears and show you something pretty cool
we’ve done to integrate with Azure dashboards.
So, here are the tiles that I just pinned when I was in the
Resource Graph Explorer and ran those queries. And rather
than sit here and try to make a beautiful dashboard on the
fly, I’ve already precreated one and we’re going to link
to it in the description below. So, I’m going to go ahead
and click upload and we’ll go into here and grab this
dashboard that I’ve downloaded. And now, what this is
going to show is basically a whole bunch of queries that
target my subscriptions. And if you upload it, it will show
your subscriptions. And it’s going to show me a whole
bunch of really interesting queries: the count of all my
resources, the top 10 that we just looked at. But then
there’s things like resource specific queries. How many VMs
do I have? How about that split by operating system or by
family? You can click on any of these tiles and get a sense
of what that query looks like right here in this context
pane.
So, we’ve done a basic inventory for compute, storage,
and networking, and Azure SQL and App Service. So, you
could download this. You could look at the queries. You
could extend it. And you can change it to suit your needs.
One final thing I will show is a new feature we did on
Azure dashboards here, which is filter. So, I can actually
come in here and just with a few clicks filter all of these
queries down to a subset of subscriptions. And I do that
and then all the tiles update and there you. So, using
this tool, Azure Resource Graph Explorer, I was able to
write some basic queries using the powerful KQL language,
create dashboards that I can slice and dice and filter. And,
of course, if you’ve seen our other dashboard videos, you
can share this dashboard very easily with others in your
organization also using role-based access control.
Leon: Thank you very much, Adam. And thanks, every
one, of you for watching. Please try this out and let us
know what you think. Leave us a comment in the video.
Follow us on Twitter. And look forward to seeing you in the
next video. Thank you very much.