Open In App

Microsoft Azure – Scaling Inventory Resources

Last Updated : 31 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will learn how to inventory resources at scale using the Azure Portal and the power of Azure Resource Graph. Azure has always given you a way to inventory your resources for a single subscription. 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, Azure has 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. Azure plans on replanting significant portions of the experience, like its search and all of the lists of resources you see on top of Resource Graph.

Implementation:

In this article, we are going to look into a tool Azure has built that lets you get to the core of Azure Resource Graph and what it can provide. So for that, you will be going to use the Resource Graph Explorer tool, so you can go to search and just type Resource Graph Explorer. . And what you are going to see is a familiar query editing and execution experience that you will see in other kinds of database solutions. 

Now, let’s start with the most basic thing, just counting your resources. As mentioned before, if you have got a lot of subscriptions, then writing that script would be tough. But with Resource Graph, it’s as easy as you are going to type count. You are going to run a query. And done. You can go ahead and save this query. And let’s just call it My count. 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. So, go ahead and pin that to your dashboard.

But the KQL query language is much more powerful than that. Let’s say you want to get an understanding of the different types of resources you have. Summarize count=count by type. And now, you can see all the different resource types that you have and their counts. Even better, let’s say there are lots of them, let’s say you just want to get a sense of the top 10. So, you will go ahead, and say order by count descending take 10. So, the most frequent resources appear on your subscriptions. You could even come over to the charts table. And you can pin that to your dashboard as well.

On the left, you will see a tree that shows all the different types of resources that are in the subscriptions you have access to. And you can unfold this and take a look at all the different specific types that you can query on.

Rather than doing that one by one, go to switch gears and see what Azure has done to integrate with Azure dashboards. So, here are the tiles that you just pinned when you were in the Resource Graph Explorer and ran those queries. You have already created a dashboard and you can go to the link to it in the description below. So, go ahead and click upload and you will go into and grab the dashboard that you have 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 you a whole bunch of really interesting queries: the count of all your resources, the top 10 that you just looked at. But then there are things like resource-specific queries. How many VMs do you 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, these are 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 is a new feature on Azure dashboards here, which is the filter.

So, you can actually come in here and just with a few clicks filter all of these queries down to a subset of subscriptions. And you do that and then all the tiles update. So, using this tool, Azure Resource Graph Explorer, you were able to write some basic queries using the powerful KQL language, create dashboards that you can slice and dice, and filter. And, of course, if you’ve seen Azure other dashboard videos, you can share this dashboard very easily with others in your organization also using role-based access control.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads