Search code examples
azureazure-application-insights

How to periodically run a Azure log query?


I need the count of a particular request from an App that I am running in Azure. I have created a query to do such stuff. Is there any way to periodically run this query and store the result (maybe email it automatically would be great) ? I do the query from App Insights.


Solution

  • Build a small timer-triggered Azure Function, use the Azure Monitor Query SDK and for example an SendGrid output binding to send the mail.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-csharp

    https://learn.microsoft.com/en-us/dotnet/api/overview/azure/monitor.query-readme?view=azure-dotnet

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-sendgrid?tabs=in-process%2Cfunctionsv2&pivots=programming-language-csharp