Skip to content

Instantly share code, notes, and snippets.

@seanmcdonnellblog
Last active July 13, 2019 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanmcdonnellblog/7b0c3e91f6d22af1bff021483b0c939b to your computer and use it in GitHub Desktop.
Save seanmcdonnellblog/7b0c3e91f6d22af1bff021483b0c939b to your computer and use it in GitHub Desktop.
# Global Variables
$resourceType = 'microsoft.storage/storageAccounts'
## EXAMPLE 1 - Find tags for Storage Accounts
$query = "where type =~ '$resourceType' | project name, resourceGroup, type, location, tags"
Search-AzGraph -Query $query
## EXAMPLE 2 - Display Count for the Service Tag
$query = "where type =~ '$resourceType' | project tag = tostring(tags.Service) | summarize count() by tag"
Search-AzGraph -Query $query
## EXAMPLE 3 - Count count of Storage Accounts by location
$query = "where type =~ '$resourceType' | summarize count() by location"
Search-AzGraph -Query $query
## EXAMPLE 4 - Find any Storage accounts that are not VNET integrated (Accessible from Internet)
$query = "where type =~ '$resourceType' and aliases['Microsoft.Storage/storageAccounts/networkAcls.defaultAction'] == 'Allow' `
| project name, kind, location"
Search-AzGraph -Query $query
## EXAMPLE 5 - Find any storage accounts which are not located in Primary Loation UK South
$query = "where type =~ '$resourceType' and aliases['Microsoft.Storage/storageAccounts/primaryLocation'] != 'uksouth' | `
project name, location, resourceGroup"
Search-AzGraph -Query $query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment