More Info:
A log profile controls how the activity log is exported and retained. Since the average time to detect a breach is 210 days, the activity log should be retained for 365 days or more in order to have time to respond to any incidents.Risk Level
LowAddress
Security, Operational MaturityCompliance Standards
HIPAA, ISO27001Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Ensure activity log retention is set for 365 days or greater” in Azure using Azure console, follow the below steps:
- Login to the Azure portal (https://portal.azure.com/).
- Click on the “Azure Active Directory” icon from the left-hand side menu.
- Select the “Activity log” option from the left-hand side menu.
- Click on the “Export settings” option from the top menu.
- In the “Export settings” page, select the “Retention (days)” option.
- Enter “365” or greater in the “Retention (days)” field.
- Click on the “Save” button to save the changes.
Using CLI
Using CLI
To remediate the misconfiguration of activity log retention for Azure using Azure CLI, follow the below steps:Step 1: Open the Azure CLI command prompt.Step 2: Run the following command to set the activity log retention to 365 days or greater:Note: Replace This command will show the details of the log profile that you just created.Step 4: Once verified, you can close the Azure CLI command prompt.By following these steps, you have successfully remediated the misconfiguration of activity log retention for Azure using Azure CLI.
<location> with the location where you want to create the log profile.Step 3: Verify the configuration by running the following command:Using Python
Using Python
To remediate the misconfiguration of activity log retention for Azure using Python, you need to use the Azure SDK for Python. Here are the steps to remediate the issue:
- Install the Azure SDK for Python by running the following command in the terminal:
- Import the necessary modules in your Python script:
- Set the credentials for your Azure account by creating a Service Principal and assigning it the appropriate permissions. You will need to provide the following details in your script:
- Tenant ID
- Client ID
- Client Secret
- Subscription ID
- Create a MonitorManagementClient object using the credentials and subscription ID:
- Retrieve the current retention period for activity logs:
- If the retention period is less than 365 days, update the retention policy:
- Run the script to remediate the misconfiguration.

