How to List ResourceGroup Locks using Azure Resource Graph

Siva Kalluri 0 Reputation points
2025-05-14T13:13:00.76+00:00

I need an Azure Resource Graph query to list the resource group locks. I have tried AuthorizationResources and ResourceContainers tables, but they don’t seem to retrieve the resource group locks. Any help would be appreciated.

Azure Data Explorer
Azure Data Explorer

An Azure data analytics service for real-time analysis on large volumes of data streaming from sources including applications, websites, and internet of things devices.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Luis Arias 9,536 Reputation points Volunteer Moderator
    2025-05-14T13:44:20.75+00:00

    Hello Siva,

    As far as I know Resource locks are not currently available in Azure Resource Graph. As alternative you can use Azure CLI to list resource lock in a subscription:

    SUBSCRIPTION_ID=$(az account show --query id -o tsv)
    
    # Get all resource groups in the subscription
    az group list --query "[].name" -o tsv | while read -r rg; do
        echo "Resource group: $rg"
        az lock list --resource-group "$rg" --query "[].{Scope:scope, Name:name, Level:level}" -o table
    done
    
    # List subscription-level locks
    echo "Subscription-level locks:"
    az lock list --scope /subscriptions/$SUBSCRIPTION_ID --query "[].{Scope:scope, Name:name, Level:level}" -o table
    

    If the information helped address your question, please Accept the answer.

    Luis

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.