Overview
Create an activity log alert for the "Delete Policy Assignment" event.
Rationale
Monitoring for "Delete Policy Assignment" events gives insight into changes done in "Azure policy - Assignments" and can reduce the time it takes to detect unsolicited changes.
Remediation guidance
From Azure Console
- Navigate to the
Monitorblade. - Select
Alerts. - Select
Create. - Select
Alert Rule. - Under
Scope, clickSelect scope. - Select your subscription and click
Apply. - Select the
Conditiontab. - Under
Signal name, clickDelete Policy Assignment (Microsoft.Authorization/policyAssignments). - Select the
Actionstab. - Click
Done. - To use an existing action group, click
Select action groups. To create a new action group, clickCreate action group. Fill out the appropriate details for the selection. - Select the
Detailstab. - Select a
Resource Group, provide anAlert rule nameand an optionalAlert rule description. - Click
Review + create. - Click
Create.
Using Azure Command Line Interface
Use the below command to create an Activity Log Alert for Delete Policy Assignment.
az monitor activity-log alert create --resource-group "<resource group name" --condition category=Administrative and operationName=Microsoft.Authorization/policyAssignments/delete and level=verbose --scope "/subscriptions/<subscription ID>" --name "<activity log rule name>" --subscription <subscription ID> --action-group <action group ID>
Using Azure Powershell
Create the conditions object.
$conditions = @()
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Administrative -Field category
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Microsoft.Authorization/policyAssignments/delete -Field operationName
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Verbose -Field level
Get the Action Group information and store it in a variable, then create a new Action object.
$actionGroup = Get-AzActionGroup -ResourceGroupName <rg_name> -Name <action group name>
$actionObject = New-AzActivityLogAlertActionGroupObject -Id $actionGroup.Id
Create the scope variable.
$scope = "/subscriptions/<subscription ID>"
Create the Activity Log Alert Rule for Microsoft.Authorization/policyAssignments/delete.
New-AzActivityLogAlert -Name "<activity alert rule name>" -ResourceGroupName "<rg_name>" -Condition $conditions -Scope $scope -Location global -Action $actionObject -Subscription “<subscription ID>” -Enabled $true
Default Value
By default, no monitoring alerts are created.
References
- https://learn.microsoft.com/en-in/azure/azure-monitor/platform/alerts-activity-log
- https://learn.microsoft.com/en-in/rest/api/monitor/activitylogalerts/createorupdate
- https://learn.microsoft.com/en-in/rest/api/monitor/activitylogalerts/listbysubscriptionid
- https://learn.microsoft.com/en-us/security/benchmark/azure/security-controls-v3-logging-threat-detection#lt-3-enable-logging-for-security-investigation
- https://azure.microsoft.com/en-us/services/blueprints/
Service-wide remediation
Recommended when many resources are affected: fix the platform baseline first so new resources inherit the secure setting, then remediate the existing flagged resources in batches.
Azure
Use management group or subscription Azure Policy assignments, remediation tasks where supported, landing-zone standards, and IaC modules so drift is prevented at scale.
Operational rollout
- Fix the baseline first at the account, subscription, project, cluster, or tenant scope that owns this control.
- Remediate the currently affected resources in batches, starting with internet-exposed and production assets.
- Re-scan and track approved exceptions with an owner and expiry date.
Query logic
These are the stored checks tied to this control.
Activity Log Alert exists for Delete Policy Assignment
Connectors
Covered asset types
Expected check: eq []
query ($subscriptionResourceId: String!) {
AzureActivityLogAlertsForAction(
subscriptionResourceId: $subscriptionResourceId
equals:"microsoft.authorization/policyassignments/delete"){...AssetFragment}}
Microsoft Azure