asgerhallas
asgerhallas

Reputation: 17724

Read logs from within an Azure Function

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

Answers (2)

RithwikBojja
RithwikBojja

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:

enter image description here

Then in next step I have chosen the Azure Applications insights like below:

enter image description here

Then I have opted send an email action and then I got the logs to my email :

enter image description here

enter image description here

Then in email I received logs:

enter image description here

Upvotes: 2

Farrukh Normuradov
Farrukh Normuradov

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".

  1. 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.

  2. 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.

two solutions

Upvotes: 2

Related Questions