https://learn.microsoft.com/en-us/azure/azure-functions/functions-monitor-log-analytics?tabs=python

Use logging like this

So we followed the tutorial and created a log analytics workspace

Then we added that workspace to the function app to store logs for 7 days

The we can do query’s on logs

We can now set up the logging in the app

example, logging.info(“ALERTMSG-COIN”)

Then we can set up an alert and trigger for that word.

Select

Email/SMS message/Push/Voice: Send various notification types to specific recipients.

The above language is Kusto.

After you have configured it, you will get a mail.

Now we test with injecting that logging statement in the code and publish and wait.

Clear logs

https://learn.microsoft.com/en-us/azure/azure-monitor/logs/data-retention-archive?tabs=portal-1%2Cportal-2

Purge

{
	table: "FunctionAppLogs",
"filters":  [
          {
            "column": "Message",
            "operator": "==",
            "value": "ALERTMSG-COIN"         
          }
        ]   
}

https://learn.microsoft.com/en-us/rest/api/loganalytics/workspace-purge/purge?tabs=HTTP#code-try-0

A status should be returned, use that in GET STATUS for purge-id

https://learn.microsoft.com/en-us/rest/api/application-insights/components/get-purge-status?tabs=HTTP#code-try-0

It takes time

It is started…..

https://stackoverflow.com/questions/62634266/how-to-delete-logs-from-azure-using-custom-conditions

How long does t take?

https://learn.microsoft.com/en-us/services-hub/health/purge_assessment_data_in_log_analytics

If we get Response code as 202 and we get operation id back, we are good and data will be purged soon.

app

https://coinfun01qa.azurewebsites.net/api/coinfun01qa