Overview
Create an activity log alert for the Delete SQL Server Firewall Rule event.
Rationale
Monitoring for Delete Server Firewall Rule events gives insight into network access changes and may reduce the time it takes to detect suspicious activity.
Impact
There will be a substantial increase in log size if there is a large number of administrative actions on a server.
Remediation guidance
From Azure Console
- Go to
Monitor - Select
Alerts - Click on
Createand selectAlert rule - Under
Scope, clickSelect scope - Select the appropriate subscription and click
Apply - Under
ConditionclickSee all signals - Select the
Delete server firewall rule (Server Firewall Rule)signal - Click
Apply - Under
Actions, clickSelect action groupsto pick an existing action group or clickCreate action groupand fill in the necessary details to create a new action group - Under
Details, select the appropriate resource group to save the alert to, and an alert name - Under
Review + create, check theEnable upon creationcheckbox - Click
Create
Using Azure Command Line Interface
Use the below command to create an Activity Log Alert for Delete SQL Firewall Rule
az monitor activity-log alert create --resource-group "<resourceGroup>" --condition category=Administrative and operationName=Microsoft.Sql/servers/firewallRules/delete and level=<verbose | information | warning | error | critical> --scope "/subscriptions/<subscriptionID>" --name "<activityLogRuleName>" --subscription <subscriptionID> --action-group <actionGroupID> --location global
Using Azure PowerShell
Create the Conditions object.
$conditions = @()
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Administrative -Field category
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Microsoft.Sql/servers/firewallRules/delete -Field operationName
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject -Equal Verbose -Field level
Retrieve the Action group information and store it in a variable, then create the Actions object.
$actionGroup = Get-AzActionGroup -ResourceGroupName <resourcegroup> -Name <actionGroup>
$actionObject = New-AzActivityLogAlertActionGroupObject -Id $actionGroup.Id
Create the Scope object.
$scope = "/subscriptions/<subscriptionID>"
Create the Activity Log Alert Rule for Microsoft.Sql/servers/firewallRules/delete
New-AzActivityLogAlert -Name "<activityLogRuleName>" -ResourceGroupName "<resourceGroup>" -Condition $conditions -Scope $scope -Location global -Action $actionObject -Subscription <subscriptionID> -Enabled $true
Default Value
By default, no monitoring alerts are created.
References
- https://azure.microsoft.com/en-us/updates/classic-alerting-monitoring-retirement
- 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
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 SQL Server Firewall Rule
Connectors
Covered asset types
Expected check: eq []
query ($subscriptionResourceId: String!) {
AzureActivityLogAlertsForAction(
subscriptionResourceId: $subscriptionResourceId
equals:"microsoft.sql/servers/firewallrules/delete"){...AssetFragment}}
Microsoft Azure