Monitoring your Function App with ease

This post was created thanks to great support from people directly involved in Azure Functions in Mi

This post was created thanks to great support from people directly involved in Azure Functions in Microsoft - Donna Malayeri and Paul Batum

Introduction

Azure Functions make developing small services easier, especially with all those triggers and bindings, which allow you to skip writing boilerplate code and focus directly on your business needs. They are also provided with a possibility to "pay-as-you-go" with Consumption Plan supported. Currently many people take advantage of this feature and try to make the most of it by not exceeding a monthly free cap of executions and execution time. What if you'd like to monitor somehow how many times you function's been executed? Fortunately there're two ways of doing it and both are a piece of cake.

A graph presenting executions of a function triggered once per 5 minutes

Using Azure Portal

The easiest way to monitor your Function App(unfortunately you cannot monitor each function separately, at least not now) is to go to portal and check metrics of an App service plan, which is used to host it(to be more specific - its metrics). To do so I'll quote Paul directly here:

/
> There appears to be a bug that is making this harder than it should be. Try the following steps...
> Open Function App. Platform Features -> All Settings -> Click on Function Execution Count graph -> uncheck count, check units.

By doing those steps, you should be able to see a chart with a metric selected:

Weekly metrics of my function

There's one gotcha here however:

/
> Function Execution units are in mbmilliseconds, you'll need to divide by 1024000 to get gbsec.

One more thing - there's now way to know what's the aggregated value e.g. from a month - for now you have to do it on your own.

Using API

There's one more way to check the metrics - using a REST API of Azure Monitoring. This method is described on StackOverflow also by Paul and with a direct reference to walkthrough of Azure Monitoring REST API. The main idea is to call API, which will return to you something similar to following:

/
{
  "value": [
    {
      "data": [
        {
          "timeStamp": "2016-12-10T00:00:00Z",
          "total": 0
        },
        {
          "timeStamp": "2016-12-10T00:01:00Z",
          "total": 140544
        },
        {
          "timeStamp": "2016-12-10T00:02:00Z",
          "total": 0
        },
        {
          "timeStamp": "2016-12-10T00:03:00Z",
          "total": 0
        },
        {
          "timeStamp": "2016-12-10T00:04:00Z",
          "total": 0
        }
      ],      
      "name": {
        "value": "FunctionExecutionUnits",
        "localizedValue": "Function Execution Units"
      },
      "type": "Microsoft.Insights/metrics",
      "unit": "0"
    }
  ]
}

Once you have the result, it's easy to write a custom tool, which will calculate all metrics and give you an insight into your's functions performance.

 

Comments (1) -

586159 85385This web site is really a walk-through for all of the info you wanted about this and didn�t know who to ask. Glimpse here, and you�ll definitely discover it. 748850

Add comment