Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Azure Monitor activity log is a platform log for control plane events from Azure resources. It includes information like when a resource is modified or when a deployment error occurs. Use the activity log to either review or audit this information for resources that you monitor, or create an alert to be proactively notified when an event is created.
Tip
If you were directed to this article from a deployment operation error, see Troubleshoot common Azure deployment errors.
Activity log entries
Entries in the activity log are collected by default with no required configuration. They're system generated and can't be changed or deleted. Entries are typically a result of changes (create, update, delete operations) or an action having been initiated. Operations focused on reading details of a resource aren't typically captured. For a description of activity log categories, see Azure activity log event schema.
Note
Operations above the control plane are logged in Azure Resource Logs. These aren't collected by default and require a diagnostic setting to be collected.
Retention period
Activity log events are retained in Azure for 90 days and then deleted. There's no charge for entries during this time regardless of volume. For more functionality, such as longer retention, create a diagnostic setting and route the entries to another ___location based on your needs.
View and retrieve the activity log
You can access the activity log from most menus in the Azure portal. The menu that you open it from determines its initial filter. If you open it from the Monitor menu, the only filter is on the subscription. If you open it from a resource's menu, the filter is set to that resource. You can always change the filter to view all other entries. Select Add Filter to add more properties to the filter.
You can also access activity log events by using the following methods:
- Use the Get-AzLog cmdlet to retrieve the activity log from PowerShell. See Azure Monitor PowerShell samples.
- Use az monitor activity-log to retrieve the activity log from the CLI. See Azure Monitor CLI samples.
- Use the Azure Monitor REST API to retrieve the activity log from a REST client.
View change history
For some events, you can view the change history, which shows what changes happened during that event time. Select an event from the activity log you want to look at more deeply. Select the Change history tab to view any changes on the resource up to 30 minutes before and after the time of the operation.
If any changes are associated with the event, you'll see a list of changes that you can select. Selecting a change opens the Change history page. This page displays the changes to the resource. In the following example, you can see that the VM changed sizes. The page displays the VM size before the change and after the change. To learn more about change history, see Get resource changes.
Activity log insights
Activity log insights is a workbook that provides a set of dashboards that monitor the changes to resources and resource groups in a subscription. The dashboards also present data about which users or services performed activities in the subscription and the activities' status.
To enable activity log insights, export the activity log to a Log Analytics workspace as described in Export activity log. This sends events to the AzureActivity
table which is used by activity log insights.
You can open activity log insights at the subscription or resource level. For the subscription, select Activity Logs Insights from the Workbooks section of the Monitor menu.
For an individual resource, select Activity Logs Insights from the Workbooks section of the resource's menu.
Export activity log
Create a diagnostic setting to send activity log entries to other destinations for additional retention time and functionality. See Diagnostic settings in Azure Monitor for the detailed steps to create a diagnostic setting.
The information below provides further details on the different destinations that resources logs can be sent to.
Send the activity log to a Log Analytics workspace for the following functionality:
- Correlate activity logs with other log data using log queries.
- Create log alerts which can use more complex logic than activity log alerts.
- Access activity log data with Power BI.
- Retain activity log data for longer than 90 days.
There are data ingestion or retention charges for activity logs for the default retention period of 90 days. You can increase the retention period to up to 12 years.
Activity log data in a Log Analytics workspace is stored in a table called AzureActivity. The structure of this table varies depending on the category of the log entry.
For example, to view a count of activity log records for each category, use the following query:
AzureActivity
| summarize count() by CategoryValue
To retrieve all records in the administrative category, use the following query:
AzureActivity
| where CategoryValue == "Administrative"
Important
In some scenarios, it's possible that values in fields of AzureActivity
might have different case from otherwise equivalent values. When querying data in AzureActivity
, use case-insensitive operators for string comparisons, or use a scalar function to force a field to a uniform casing before any comparisons. For example, use the tolower() function on a field to force it to always be lowercase or the =~ operator when performing a string comparison.
Export to CSV
Select Download as CSV to export the activity log to a CSV file using the Azure portal.
Important
The export may take an excessive amount of time if you have a large number of log entries. To improve performance, reduce the time range of the export. In the Azure portal, this is set with the Timespan setting.
You can also export the activity log to a CSV file using PowerShell or the Azure CLI as in the following examples.
az monitor activity-log list --start-time "2024-03-01T00:00:00Z" --end-time "2024-03-15T23:59:59Z" --max-items 1000 > activitylog.json
Get-AzActivityLog -StartTime 2021-12-01T10:30 -EndTime 2022-01-14T11:30 | Export-csv operations_logs.csv
The following example PowerShell script exports the activity log to CSV files in one hour intervals, each being saved to a separate file.
# Parameters
$subscriptionId = "Subscription ID here" # Replace with your subscription ID
$startTime = [datetime]"2025-05-08T00:00:00" # Adjust as needed
$endTime = [datetime]"2025-05-08T12:00:00" # Adjust as needed
$outputFolder = "\Logs" # Change path as needed
# Ensure output folder exists
if (-not (Test-Path $outputFolder)) {
New-Item -Path $outputFolder -ItemType Directory
}
# Set subscription context
Set-AzContext -SubscriptionId $subscriptionId
# Loop through 1-hour intervals
$currentStart = $startTime
while ($currentStart -lt $endTime) {
$currentEnd = $currentStart.AddHours(1)
$timestamp = $currentStart.ToString("yyyyMMdd-HHmm")
$csvFile = Join-Path $outputFolder "ActivityLog_$timestamp.csv"
Write-Host "Fetching logs from $currentStart to $currentEnd..."
Get-AzActivityLog -StartTime $currentStart -EndTime $currentEnd |
Export-Csv -Path $csvFile -NoTypeInformation
$currentStart = $currentEnd
}
Write-Host "Export completed. Files saved to $outputFolder."
Next steps
Learn more about: