Reputation: 17724
I have an Azure function that runs a few times a day. I'd like to email myself a daily list of log messages, and wondered if I could use another Azure function for that?
Is it possible to read an Azure function logs from within an Azure function? Or is there another way to achieve the above?
Upvotes: 2
Views: 254
Reputation: 11183
Or is there another way to achieve the above?
Yes, you can use Azure Logic apps to get the logs of Function app recurrently. I have created a logic app in Consumption plan, then created a workflow with Recurrence Trigger like below:
Then in next step I have chosen the Azure Applications insights like below:
Then I have opted send an email action and then I got the logs to my email :
Then in email I received logs:
Upvotes: 2
Reputation: 1184
I would propose two possible solutions in the realm of Azure.
In both cases I would suggest to include application insights.
It is a general recommendation by Microsoft.
Then goes what Peter Bons called "use case".
If it is enough for you get the critical information about recurring issues with N minutes of frequency, then you could make us of alerts. Last time I checked one needed to pay extra for each email, please double-check that.
If for some reason you want to have more control over what logs you want to send and fetch, you can fetch data directly from application insights through the REST API. To complete the idea you could use bindings that allow send emails (see here for practical points). I would say that there variations on how you can achieve fetching data, although the feature will be deprecated in two years.
Upvotes: 2