Wednesday, October 7, 2015

Access Storage Logs with PowerShell Commands

When Storage Logging is configured, log data is saved to blobs in the $logs container created for the storage account.

You can access logs with the Get-AzureStorageBlob command and filter logs by filename and metadata.

Get-AzureStorageBlob -Container '$logs' |
where {
    $_.Name -match 'blob/YYYY/MM/DD/HHMM' -and
    $_.ICloudBlob.Metadata.LogType -match 'write'
}
foreach {
 "{0}{1}{2}{3}" -f $_.Name,
 $_ICloudBlob.Metadata.StartTime,
 $_ICloudBlob.Metadata.EndTime,
 $_ICloudBlob.Metadata.LogType
}
           

No comments:

Post a Comment