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 Diagnostic Settings Storage Retention feature has being deprecated. You can no longer create new retention rules, although you can still see and modify any existing retention settings. All retention functionality for the Diagnostic Settings Storage Retention feature will be disabled across all environments on September 30, 2025.
This article walks through migrating from using Azure diagnostic settings storage retention to using Azure Storage lifecycle management for retention. For logs sent to a Log Analytics workspace, retention is set for each table on the Tables page of your workspace. For more information on Log Analytics workspace retention, see Manage data retention in a Log Analytics workspace.
Prerequisites
An existing diagnostic setting logging to a storage account.
Migration procedures
Note
When you change your retention settings, the new settings only apply to new logs ingested after the change. Existing logs are subject to the previous retention settings.
Deleting a diagnostic setting doesn't delete the logs in the storage account. The retention settings will continue to apply to the logs created before the diagnostic settings were deleted.
Use the following CLI command to check if a resource has a diagnostic setting:
az monitor diagnostic-settings list --resource <resource Id>
The output shows whether the diagnostic setting sends the data to a storage account, for example:
[
{
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourcegroups/rg-001/providers/microsoft.insights/datacollectionrules/dcr-east2/providers/microsoft.insights/diagnosticSettings/dsetting-1",
"logs": [
{
"categoryGroup": "allLogs",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": false,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"name": "dsetting-1",
"resourceGroup": "rg-001",
"storageAccountId": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/rg-DCR/providers/Microsoft.Storage/storageAccounts/logs001",
"type": "Microsoft.Insights/diagnosticSettings"
}
]
To migrate your diagnostics settings retention rules, follow the steps below:
Go to the Diagnostic Settings page for your logging resource and locate the diagnostic setting you wish to migrate.
Set the retention for your logged categories to 0.
Select Save
Navigate to the storage account you're logging to.
Under Data management, select Lifecycle Management to view or change lifecycle management policies.
Select List View, and select Add a rule.
Enter a Rule name.
Under Rule Scope, select Limit blobs with filters.
Under Blob Type, select Append Blobs and Base blobs under Blob subtype.
Select Next.
Set your retention time, then select Next.
On the Filters tab, under Blob prefix set path or prefix to the container or logs you want the retention rule to apply to. The path or prefix can be at any level within the container and will apply to all blobs under that path or prefix.
For example, for all insight activity logs, use the container insights-activity-logs to set the retention for all of the logs in that container. To set the rule for a specific webapp app, use insights-activity-logs/ResourceId=/SUBSCRIPTIONS/<your subscription Id>/RESOURCEGROUPS/<your resource group>/PROVIDERS/MICROSOFT.WEB/SITES/<your webapp name>.
Use the Storage browser to help you find the path or prefix. The example below shows the prefix for a specific web app: *insights-activity-logs/ResourceId=/SUBSCRIPTIONS/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/RESOURCEGROUPS/rg-001/PROVIDERS/MICROSOFT.WEB/SITES/appfromdocker1. To set the rule for all resources in the resource group, use insights-activity-logs/ResourceId=/SUBSCRIPTIONS/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e7/RESOURCEGROUPS/rg-001.
Select Add to save the rule.