Search code examples
azureazure-active-directoryazure-web-app-serviceazure-log-analyticsazure-alerts

How to set alert on edit/delete of a file or folder in Azure Portal


Log files for my sample application is getting created in the following folder in azure portal D:/home/LogFiles/sample_application/sample_application.log

sample_application.log can be both edited and deleted.

Is there a way in azure portal to trigger an email alert when someone tries to modify or delete the log file??

Log File Location in Kudu Console


Solution

  • • Yes, you can surely configure an alert using the Azure Monitor regarding the deletion of the log file from the App service through the kudu console or by some other means. For this purpose, you will have to create an alert rule from the Azure Monitor alerts pane with the condition ‘ AppServiceFileAuditLogs | where OperationName == “Delete” and Path == “D:/home/LogFiles/sample_application/sample_application.log” ’ with the action of sending an alert to the email id as registered with this alert rule. Please find the link below on how to create an alert rule through Azure Monitor: -

    https://learn.microsoft.com/en-us/azure/azure-monitor/alerts/alerts-activity-log

    Also find the below snapshot below for reference: -

    Log query in log analytics workspace

    Also, ensure that condition is selected as ‘Custom Log Search’ for as below: -

    Azure monitor log alert condition

    Please find the link below for detailed instructions on implementing the integration between Azure app service and Azure monitor: -

    https://azure.github.io/AppService/2019/11/01/App-Service-Integration-with-Azure-Monitor.html