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 disable the classic diagnostics settings for Azure storage account.
$storageAccounts = Get-AzStorageAccount
foreach ($storageAccount in $storageAccounts) {
try {
Write-Output "Disabling classic diagnostics settings for storage account: $($storageAccount.StorageAccountName) in subscription: $($subscription.Name)"
# Get the storage account context
$storageAccountContext = $storageAccount.Context
# Disable classic logging by setting logging operations to None
Set-AzStorageServiceLoggingProperty -ServiceType Blob, Table, Queue -Context $storageAccountContext -LoggingOperations None -RetentionDays 0
} catch {
Write-Output "Failed to disable classic diagnostics settings for storage account: $($storageAccount.StorageAccountName). Error: $_"
}
}
disabling azure classic storage account diagnostics
According to this MS-Document the powershell command doesn't support file service.
You can use the Azure CLI command to disable the azure Storage Diagnostic (Classic).
Command:
retention=0
for account in $(az storage account list --query "[].name" --output tsv)
do
storage_account_key=$(az storage account keys list --account-name $account --query "[0].value" --output tsv)
az storage metrics update --services bqtf --hour false --minute false --api false --retention $retention --account-name $account --account-key $storage_account_key
az storage logging off --services bqt --account-name $account --account-key $storage_account_key
done
Output:
The above script executed and disabled the Diagnostic settings (classic)
.
Reference: