All about monitoring your Azure Functions
Published: 2022-07-18 07:26:09

This blog centers on core concepts of Azure Function and how it tends to be better monitored using Serverless360. To comprehend Azure Function Apps more readily, let us think about a real-world business scenario of Order Processing to understand the pain points that we have. Before getting into the Business scenario, let’s do a quick look at Azure Functions and their attributes.

## What is Azure Function?
Azure Function is a serverless compute service that enables users to run event-triggered code without providing or managing infrastructure. A trigger-based service runs a script or code in response to various events.

Azure Functions can be used to achieve decoupling, high throughput, and reusability. It can also be used for production environments.


Azure Functions can be triggered with configured triggers like HTTP Trigger, Timer Trigger, Queue Trigger, and more. Workflow in Azure Functions can be defined using Azure Durable Function. It consists of an Orchestrator Function that has the workflow defined with several Activity Functions.

## Where Are Azure Functions Used?

Azure Functions are the most appropriate for more modest applications with occasions that can work freely on different sites. Standard Azure Functions send emails, start a backup, order processing, task scheduling such as database clean up, sending notifications, messages, and IoT data processing.

## When to use Azure functions
Consider Functions for errands like image or order processing, file maintenance, or any tasks you want to run on a schedule. Functions provide templates to get you started with critical scenarios.

Azure Functions upholds triggers, ways to start executing your code, and bindings, which simplify coding for input and output data. There are other integration and automation services in Azure, and they all can solve integration problems and automate business processes. They can all define input, actions, conditions, and output.

For any Azure Functions, a solitary Function execution has a limit of 5 minutes naturally to execute. If the Function is running longer than the maximum timeout, then the Azure Functions runtime can end the process at any point after the maximum timeout has been reached.


## Azure Functions Advantages
Being a cloud service, the Azure Function has a lot of advantages. 

**Pay as you go model** – Azure Functions comes in the Pay as you go model. Users can pay only for what they use. For Azure functions, the cost is based on the Number of Executions per month. The cost structure of Azure Functions is mentioned above in the Pricing Section.

**Supports a variety of Languages** – Azure Function supports significant languages like Java, C#, F#, Python, and more.

**Easy Integration with Other Azure services** – Azure Functions can be easily integrated with the other Azure Services like Azure Service Bus, Event Hubs, Event Grids, Notification Hubs, and more without any hassle.

**Trigger-based executions** - Azure Functions get executed based on the configured triggers. It supports various triggers like HTTP Triggers, Queue Trigger, Event Hub Trigger, and more. Being a trigger-based service, it runs on demand. Refer to the Trigger section above to know more about the available triggers.

## Azure Function App
Azure Functions are the individual Functions created in a Function App. Each Function can be invoked using the configured trigger. The Azure portal provides the capabilities to develop, manage, monitor, and integrate inputs & outputs of the Azure Functions.

An Azure Function can also be tested by providing some raw inputs. When it comes to monitoring the Functions, the portal offers solutions like Application insights for live status monitoring through the invocation logs. Functions in a Function App can be monitored based on the app metrics.


## Azure Monitor
Azure Monitor can be used to monitor the Azure services from various perspectives. It maximizes the availability and performance of the application or service.

Azure Monitor offers several services like Application Insights, Log Analytics, Alerts, and Dashboards. It also integrates Power BI, Event Hubs, Logic Apps, and API.

### Metrics Explorer:
With Metrics Explorer, the user can detect the application’s performance and latency or the service in the chart view. This metric explorer shows the analytics results based on the filters configured on the extensive set of metrics.

### Log Analytics:
Log Analytics is a tool used to manage Azure Monitor queries. With Log Analytics, users can perform monitoring and diagnostics logging for Azure Logic Apps. Users can also query the log for efficient debugging.

### Alerts:
With Alerts in Azure Monitor, users can get the alert report when there is a violation. These Alerts are also based on the configured metrics while creating it. A single alert can only monitor a single entity based on several metrics configured.

## Serverless360 for Azure Function App
Azure Function Apps can settle colossal business challenges, but managing and monitoring them in Azure Portal is quite challenging. So here comes Serverless360, which manages and monitors the Azure resources in the application context. With Serverless360, Azure Functions can be managed, monitored, and analyzed from various perspectives. Let’s jump into the exciting features that Serverless360 has in a glance underneath.

## Manage Azure Functions in Serverless360
An Azure Function is a code triggered by an event, whereas an Azure Logic App is a workflow triggered by an event. Azure Functions can be monitored using Application Insights and Azure Monitor. Though Azure provides such monitoring solutions, users cannot monitor multiple entities with various metrics.

Whereas, with Serverless360 monitoring, it is possible to monitor various entities based on metrics at the Application level.

## Azure Function Overview
In Serverless360, users can also associate and manage Azure Functions from different Function Apps. Users can now enable or disable an Azure Function directly from Serverless360.

Users can keep track of their Azure Function by using the disabled status.


## Test Function
Azure Functions can be tested using Serverless360 instead of navigating to the Azure portal. The testing is supported for any trigger in a function. Using the Test Function within Serverless360 context switching can be avoided.

For example, the user will be allowed to select the request method, say GET or POST and add Headers, Query parameters, and Message body. After providing the details, a test run can be made, and the response and its status code will be displayed.


## Invoke Triggers
Serverless360 provides the capability to invoke the Function by sending a message to the Trigger. Users can achieve this by giving the Trigger details in Invoke Function screen and by sending the message. Azure Function supports different triggers like HTTP, Service Bus Queue, Timer, etc.

There may be scenarios where an invocation of the Function fails, and the user needs to reinvoke it. There is no possibility to do it apart from posting the message of the failed invocation to the Trigger of the Function (this is not feasible in Timer triggered Function). But, Serverless360 provides the capability to invoke.

For example, if the Function is a Service Bus Queue triggered one, the user can provide the Queue connection details and post the message. The Triggers supported in Serverless360 are Service Bus Queue, Service Bus Topic, Event Grid, and HTTP.


## Invocation Logs
As I mentioned before, content and context switching is always a hectic job. To avoid the switching and access to the invocation logs of Azure Functions is a significant capability provided by Serverless360 in terms of Azure Function App management. Users can now filter out the invocation logs by selecting any one of the following states:

* Succeeded,
* Failed

The invocation detail contains the following information: Invocation date, message, and Log level.


## Function App Monitoring in Serverless360
Function and Function Apps resources have been split into two resources for better monitoring at ease.

In the Function app for monitoring, you have to go to individual resources and create alerts with the respective metrics. Also, you can’t view the alerts you have created in a consolidated view. This scenario is okay when you have limited resources, but what if you have a 100+ Function?

To overcome this case, Serverless360 has a consolidated alert report generated and sent to the configured email addresses and notification channels for the configured rules of all monitored resources in a Business Application. The condition, warning, and error thresholds of all the query rules can be edited in bulk using the Save button in the Queries tab. Query rules can be updated and deleted using the options next to each saved query rule.

Also, in Serverless360, you can have a holistic view of the complete resource. It gives you the overall picture.


### Auto-correct

Serverless360 allows users to automatically correct resource status without navigating to the Azure portal. This feature relieves customers of the need to check the status of resources and manually modify them regularly.

Users can set the Autocorrect status of compatible resources by configuring monitoring rules when creating (or) editing a Business Application or by going to the monitoring section of the resources.



### Monitor User Activities

Serverless takes action and can monitor the user activities that someone/you have done within Serverless360. Through the Audit feature, users can see which user has made what changes in Serverless360.


### Violation report and Status report

There were two reports available in Serveless360 to transfer the alerts.

* Violation report,
* Status report

Violation reports can be set to send alerts based on configured duration when a threshold condition is violated in the environment.


A status report in a Business Application can be configured to receive alerts at a specific schedule (e.g., every one hour).


## Azure Function App Dashboard

Users now have access to a default Azure Function App Dashboard, which allows them to stay up to date with real-time data through enhanced data visualization. A resource Dashboard is a picturized view pre-built into each resource type and will enable users to track each resource separately using the Dashboard’s features.

It is often preferable to provide an individual dashboard for each resource that allows the user to track the resource separately rather than having an overall resource management dashboard.


Servereless360 facilitates better [Azure Functions monitoring](https://www.serverless360.com/azure-functions-monitoring-management) and management to get immediate feedback and analysing invocation logs.

## Wrap Up

I hope this blog helps you understand the basic concepts of Azure Function and how it can be better monitored using [Serverless360](https://www.serverless360.com/). You can solve enormous business challenges using Azure Function Apps, but managing and monitoring them in Azure Portal is quite challenging. With Serverless360, Azure Functions can be managed, monitored, and analyzed from various perspectives.