Reputation: 323
Is there a way to get an alert when a firewall rule is added to an Azure SQL database? I checked the monitoring blade and didn't see a metric or log event for this.
Upvotes: 2
Views: 1545
Reputation: 33
You can do this using the Activity Log. If you add a new firewall rule and check the Activity Log after a few minutes you'll see a series of entries with the operation name Update SQL server firewall rules. Click on the one with a status of Succeeded. The next page will have a New alert rule button.
You'll need to edit the condition as it sets the initiator to your username. To do this, click the condition and change the Event Initiated by value.
Upvotes: 2
Reputation: 1380
You can use a logic app to achieve that:
Conditions should be Status=Activated and OperationName="Microsoft.Sql/servers/firewallRules/write". 2. create a new alert in Monitor. The resource will be your SQL Server and the signal will be "All Administrative operations". Create a new action group and set an webhook action. Use the logic app webhook url generate in the previous step.
{
"headers": {
"Connection": "Keep-Alive",
"Expect": "100-continue",
"Host": "abc.logic.azure.com",
"User-Agent": "IcMBroadcaster/1.0",
"X-CorrelationContext": "abc",
"Content-Length": "1350",
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"schemaId": "Microsoft.Insights/activityLogs",
"data": {
"status": "Activated",
"context": {
"activityLog": {
"channels": "Operation",
"eventSource": "Administrative",
"eventTimestamp": "2019-03-09T10:00:36.549+00:00",
"eventDataId": "eventid",
"level": "Informational",
"operationName": "Microsoft.Sql/servers/firewallRules/write",
"properties": {
"originalEventTimestamp": "03/09/2019 10:00:17",
"correlationId": "correlationId",
"eventId": "eventId",
"eventName": "OverwriteFirewallRules",
"operationName": "Microsoft.Sql/servers/firewallRules/write",
"status": "Succeeded",
"description_scrubbed": "description",
"caller": "[email protected]",
"callerCredentialType": "LiveId",
"eventChannel": "OperationLogStore",
"ipAddress": "useripaddress",
"eventSource": "SQL Databases Event Supplier"
},
"resourceId": "resourceId",
"resourceGroupName": "groupname",
"resourceProviderName": "MICROSOFT.SQL",
"status": "Succeeded",
"subscriptionId": "subscriptionId",
"submissionTimestamp": "2019-03-09T10:00:36.549+00:00",
"resourceType": "microsoft.sql/servers"
}
},
"properties": {}
}
}
}
Upvotes: 2