How to enable Diagnostics for existing Azure Storage Account using PowerShell?
Thank you
You can use PowerShell to configure Storage Metrics in your storage account by using the cmdlet Set-AzureStorageServiceMetricsProperty to change the current settings.
Example 1:
$context = New-AzureStorageContext -StorageAccountName <your storageacount name> Set-AzureStorageServiceMetricsProperty -MetricsType Minute -ServiceType Blob -MetricsLevel ServiceAndApi -RetentionDays 5 -Context $context
I enabled the diagnostics like this:enable Blob metrics
If you want to enable the below Blob,Table,Queue logs, you can use the cmdlet Set-AzureStorageServiceLoggingProperty to change the current settings.
Example 2:
$context = New-AzureStorageContext -StorageAccountName <your storageacount name> Set-AzureStorageServiceLoggingProperty -ServiceType Queue -Context $context -LoggingOperations read,write,delete -RetentionDays 5
I enabled the Queue logs like this:
enable Queue logs
Update: If you just want to enable storage of diagnostic logs in a storage account,use this command:
Set-AzureRmDiagnosticSetting -ResourceId [your resource id] -StorageAccountId [your storage account id] -Enabled $true
See more details about Set-AzureRmDiagnosticSetting ,refer to this:
learn.microsoft.com/en-us/powershell/module/azurerm.insights/set-azurermdiagnosticsetting?view=azurermps-4.3.1
You can use PowerShell to configure Storage Metrics in your storage account by using the cmdlet Set-AzureStorageServiceMetricsProperty to change the current settings.
Example 1:
I enabled the diagnostics like this:enable Blob metrics
If you want to enable the below Blob,Table,Queue logs, you can use the cmdlet Set-AzureStorageServiceLoggingProperty to change the current settings.
Example 2:
I enabled the Queue logs like this:
enable Queue logs
Update: If you just want to enable storage of diagnostic logs in a storage account,use this command:
See more details about Set-AzureRmDiagnosticSetting ,refer to this:
learn.microsoft.com/en-us/powershell/module/azurerm.insights/set-azurermdiagnosticsetting?view=azurermps-4.3.1