How do I know what Storage Accounts need to be transitioned to metrics in Azure?

Israel Rodríguez Medina 5 Reputation points Microsoft Employee
2024-08-30T18:47:58.7533333+00:00

I received an email stating I am using classic metrics in Azure Storage, and I need to transition to metrics in Azure Monitor.

The email enumerated a list of subscriptions with Storage Accounts using classic metrics, but there are about 400 Storage Accounts in them, and the vast majority are not using classic metrics.

Is there a Graph query, Azure PowerShell or any other way to automate retrieving the Storage Accounts that need to be transitioned?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,196 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,105 questions
Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
295 questions
{count} vote

2 answers

Sort by: Most helpful
  1. David Broggy 5,716 Reputation points MVP
    2024-09-01T18:13:59.7466667+00:00

    Hi Israel,

    This script will list storage attributes, however I see the 'VersionProfile' field is empty on my new test storage account, so this may not help you. Here's a windows powershell script you can play with:

    Install the Az module if you haven't already:

    Install-Module -Name Az -AllowClobberr -Scope CurentUser

    1. Copy the contents below into a "runme.ps1" file and run it, eg: ./runme!.ps1

    Connect-AzAccount

    Get all subscriptions

    $subscriptions = Get-AzSubscription

    Initialize an array to store Storage Accounts using classic metrics

    $classicMetricsStorageAccounts = @()

    Iterate over each subscription

    foreach ($subscription in $subscriptions) {

    Set the context to the subscription
    
    Set-AzContext -SubscriptionId $subscription.Id
    
    Get all storage accounts in the current subscription
    
    $storageAccounts = Get-AzStorageAccount
    
    Check each storage account for classic metrics
    
    foreach ($storageAccount in $storageAccounts) {
    
    Get the metrics settings for the storage account
    
    $metricsSettings = Get-AzStorageAccountManagementPolicy -ResourceGroupName $storageAccount.ResourceGroupName -StorageAccountName $storageAccount.StorageAccountName -ErrorAction SilentlyContinue
    
    if ($metricsSettings -eq $null) {
    
    If $metricsSettings is null, this might indicate the storage account is using classic metrics
    
            $classicMetricsStorageAccounts += $storageAccount
    
        }
    
    }
    }
    

    Output the list of Storage Accounts using classic metrics

    $classicMetricsStorageAccounts | Format-Table StorageAccountName, ResourceGroupName, Location, SubscriptionId

    
    
    0 comments No comments

  2. Israel Rodríguez Medina 5 Reputation points Microsoft Employee
    2024-09-02T18:41:32.61+00:00

    I was able to find the SAs that need to be migrated with

    Get-AzDiagnosticSetting -ResourceId $storageAccount.Id
    
    0 comments No comments

Your answer

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