Migrating Azure storage account classic diagnostics to metrics

MrFlinstone 581 Reputation points
2024-09-13T15:32:42.2066667+00:00

Having read up on the document on the link here https://learn.microsoft.com/en-gb/azure/storage/common/storage-metrics-migration

I would like to get some more information on the following.

identifying storage accounts that still use the classic Azure storage analytics

The steps to complete the migration.

From what I can see on the portal, it appears what needs doing is as follows.

Find storage accounts with the Diagnostic settings (classic) set to ON.

On the storage account blade, check that on diagnostics settings is enabled for blob/file etc, and in our case diagnostics data is sent to log analytics workspace, ensure that the right ones are selected for each resource type (blob/file/queue etc)

set the Diagnostic settings (classic) set to OFF.

It would be nice to check that the above is the right approach.

I am looking for a script that will complete the above for a storage account or perhaps will write one once the steps are confirmed.

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,174 questions
{count} votes

Accepted answer
  1. Sumarigo-MSFT 46,286 Reputation points Microsoft Employee
    2024-09-16T04:57:54.5166667+00:00

    @MrFlinstone Firstly, Apologies for the delay response!

    Welcome to MIcrosoft Q&A Forum, Thank you for posting your query here!

    To identify storage accounts that still use the classic Azure storage analytics, you can follow these steps:

    Enable Storage Analytics: You need to enable Storage Analytics individually for each service you want to monitor. This can be done from the Azure portal, programmatically via the REST API, or using the client library. Use the Set Blob Service Properties, Set Queue Service Properties, Set Table Service Properties, and Set File Service Properties operations to enable Storage Analytics for each service

    Check the Status: You can check the status of Storage Analytics logs (classic) for your storage accounts. This can be done through the Azure portal or programmatically. For more details, you can refer to the Microsoft Q&A forum

    1. Migrate Classic Storage Accounts: Microsoft will retire classic storage accounts on August 31, 2024. To preserve the data in any classic storage accounts, you must migrate them to the Azure Resource Manager deployment model by that date. This migration will allow you to take advantage of the benefits of the Azure Resource Manager deployment model
    2. Monitor and Manage Logs: You can use the Azure portal to configure and manage logs for your storage accounts. For more information on enabling and managing Azure Storage Analytics logs (classic), you can refer to the Microsoft Learn article

    References

    Option 2 : To identify storage accounts that still use the classic Azure storage analytics, you can check the Diagnostic settings (classic) for each storage account. If the Diagnostic settings (classic) are set to ON, then the storage account is still using the classic Azure storage analytics.

    Steps to Complete the Migration

    Here are the steps to complete the migration from classic Azure storage analytics to Azure Monitor metrics:

    1. Identify Classic Storage Accounts: Check the Diagnostic settings (classic) for each storage account. If set to ON, the storage account is using classic Azure storage analytics
    2. Enable Diagnostic Settings for Each Resource Type: On the storage account blade, ensure that diagnostics settings are enabled for blob, file, queue, etc., and configure them to send data to the new Log Analytics workspace
    3. Disable Diagnostic Settings (Classic): Set the Diagnostic settings (classic) to OFF
    4. Retain Logs: Ensure that the Delete data checkbox is selected and set the number of days for log data retention

    Script to Complete the Migration

    You can use Azure PowerShell or Azure CLI to create a script that completes these steps for a storage account. Here is an example using Azure PowerShell:

    # Sign in to your Azure subscription
    Connect-AzAccount
    
    # Set the context to your subscription
    $context = Get-AzSubscription -SubscriptionId <subscription-id>
    Set-AzContext $context
    
    # Get the storage account context
    $storageAccount = Get-AzStorageAccount -ResourceGroupName "<resource-group-name>" -AccountName "<storage-account-name>"
    $ctx = $storageAccount.Context
    
    # Enable logging for read, write, and delete requests in the Queue service with retention set to five days
    Set-AzStorageServiceLoggingProperty -ServiceType Queue -LoggingOperations read,write,delete -RetentionDays 5 -Context $ctx
    
    # Disable logging for the table service
    Set-AzStorageServiceLoggingProperty -ServiceType Table -LoggingOperations none -Context $ctx
    

    This script will help you automate the process of enabling and disabling diagnostic settings for your storage accounts

    If you have any further questions or need additional assistance, feel free to ask!

    You can use the Azure PowerShell module to automate the above steps for multiple storage accounts. Here's an example PowerShell script that shows how to enable diagnostic settings for a storage account and send the diagnostic data to a Log Analytics workspace:

    # Set the subscription and storage account names
    $subscriptionName = "<your_subscription_name>"
    $resourceGroupName = "<your_resource_group_name>"
    $storageAccountName = "<your_storage_account_name>"
    $logAnalyticsWorkspaceId = "<your_log_analytics_workspace_id>"
    # Connect to Azure and select the subscription
    Connect-AzAccount
    Select-AzSubscription -SubscriptionName $subscriptionName
    # Get the storage account and enable diagnostic settings
    $storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName
    Set-AzStorageServiceLoggingProperty -Context $storageAccount.Context -ServiceType Blob -LoggingOperations "Read,Write,Delete" -RetentionEnabled $true -RetentionInDays 30
    Set-AzStorageServiceLoggingProperty -Context $storageAccount.Context -ServiceType File -LoggingOperations "Read,Write,Delete" -RetentionEnabled $true -RetentionInDays 30
    Set-AzStorageServiceLoggingProperty -Context $storageAccount.Context -ServiceType Queue -LoggingOperations "Read,Write,Delete" -RetentionEnabled $true -
    
    

    Please let us know if you have any further queries. I’m happy to assist you further. 


    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.