Remediation
From Azure Portal
- Navigate to the
Monitorblade. - Select
Alerts. - Select
Create. - Select
Alert rule. - Choose a subscription.
- Select
Apply. - Select the
Conditiontab. - Click
See all signals. - Select
Delete Public Ip Address (Public Ip Address). - Click
Apply. - Select the
Actionstab. - Click
Select action groupsto select an existing action group, orCreate action groupto create a new action group. - Follow the prompts to choose or create an action group.
- Select the
Detailstab. - Select a
Resource group, provide anAlert rule nameand an optionalAlert rule description. - Click
Review + create. - Click
Create.
From Azure CLI
az monitor activity-log alert create /
--resource-group {{resource-group-name}} /
--condition category=Administrative and operationName=Microsoft.Network/publicIPAddresses/delete and level={{verbose | information | warning | error | critical}} /
--scope /subscriptions/{{subscription-id}} /
--name {{activity-log-rule-name}} /
--subscription {{subscription-id}} /
--action-group {{action-group-id}}
From PowerShell
Create the Conditions object:
$conditions = @()
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject `
-Equal Administrative `
-Field category
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject `
-Equal Microsoft.Network/publicIPAddresses/delete `
-Field operationName
$conditions += New-AzActivityLogAlertAlertRuleAnyOfOrLeafConditionObject `
-Equal Verbose `
-Field level
Retrieve the Action Groupinformation and store in a variable, then create the Actions object:
$actionGroup = Get-AzActionGroup `
-ResourceGroupName {{resource-group-name}} `
-Name {{action-group-name}}
$actionObject = New-AzActivityLogAlertActionGroupObject `
-Id $actionGroup.Id
Create the Scope object:
$scope = /subscriptions/{{subscription-id}}
Create the Activity Log Alert Rule for Microsoft.Network/publicIPAddresses/delete:
New-AzActivityLogAlert `
-Name {{activity-log-alert-rule-name}} `
-ResourceGroupName {{resource-group-name}} `
-Condition $conditions `
-Scope $scope `
-Location global `
-Action $actionObject `
-Subscription {{subscription-id}} `
-Enabled $true