Open In App

Microsoft Azure – Get Unused App Service Plans and Resource Groups in Azure Portal

Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: AZURE 

In this article, we will be using the resource graph query to find the unused Azure App Service Plans and unused Azure Resource Groups. For this will be using the Resource Graph Explorer which is an Azure native tool that can be accessed from Azure Portal with ease. To run the KQL resource graph query one should have the minimum RBAC Reader role permission on the Directory or Management Group or on the Subscription/Subscriptions to find or to fetch the information of orphaned or unused Azure resource groups & app service plans resources in Azure. Finding and deleting resources will help you or your organization to reduce and save costs.

Find Unused App Service Plans in Azure Portal

Step 1: Log in to Azure Portal.

Step 2: Navigate to the Resource Graph Explorer. You can find this by searching for “Resource Graph Explorer” in the search bar at the top of the portal.

Search for resource graph

 

Step 3: Now, Select the scope of your choice which you want to query either Directory,  Management Group, or Subscription/Subscriptions. Refer image!

Select scope

 

Step 4: In the Resource Graph Explorer, copy and paste the following azure resource graph kql query to get the unused App Service Plans from a select scope.

resources
| where type =~ "microsoft.web/serverfarms"
| where properties.numberOfSites == 0
| extend Details = pack_all()
| project ResourceName=name, 
ResourceGroupName=resourceGroup, 

Location=location

This query filters the App Service Plans that are currently not being unused.

Step 5: Now select the complete query >> Click on the “Run Query” button to execute the query.

Refer to Sample Output

Run query to get output

 

Note: You can export the results by clicking on the “Download as CSV” button and selecting the format in which you want to export the data.

Find Unused Resource Groups in Azure Portal

Step 1: Log in to Azure Portal

Step 2: Search Resource Graph Explorer from azure global search to access it

Step 3: Now, Select the scope of your choice which you want to query either Directory,  Management Group, or Subscription/Subscriptions. 

Select the scope

 

Step 4: Copy and paste the below-following azure resource graph kql query to find azure orphan resource groups at the selected scope.

ResourceContainers
| where type == "microsoft.resources/
subscriptions/resourcegroups"
| extend rgAndSub = strcat(resourceGroup, 
"--", subscriptionId)
| join kind=leftouter (
    Resources
    | extend rgAndSub = strcat(resourceGroup,
     "--", subscriptionId)
    | summarize count() by rgAndSub
) on rgAndSub
| where isnull(count_)

Step 5: Now select the complete query >> Click on Run Query to view the results. 

Run the query

 

Output:

Sample output of query

 


Last Updated : 28 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads