Acquire all necessary knowledge on Azure Function App in this definite guide. In a nutshell, it covers basic Function App concepts, comparison on the versions, properties & metrics of Function App entities, tools available to manage & monitor Azure Function Apps & much more. This guide also justifies how Serverless360 turns out to be the best tool to manage & monitor the Azure Function Apps.
This Pillar Page focuses on core concepts of Azure Function and how it can be better managed and monitored using Serverless360. For the better understanding of Azure Function Apps, let us consider a real-world business scenario performing Order Processing. Before getting into the Business scenario, let’s get the basics right about Azure Functions and its characteristics.
Azure Function is a serverless compute service that enables user to run event-triggered code without having to provision or manage infrastructure. Being as a trigger-based service, it runs a script or piece of code in response to a variety of events.
Azure Functions can be used to achieve decoupling, high throughput, reusability and shared. Being more reliable, it can also be used for the production environments.
Azure Web Job is a piece of code runs in the Azure App services. It is a Cloud Service used to run background tasks. Azure Functions are built on the top of Azure Web Jobs with the added capabilities. The table below differentiates Azure Functions and Web Jobs:
|Azure Functions||Web Jobs|
|Trigger||Azure Functions can be triggered with any of the configured trigger, but it doesn’t run continuously||Web Jobs is of two types, Triggered Web Jobs and Continuous Web Jobs|
|Deployment||Azure Functions is a separate App Service that run in the App Service Plan||Web Jobs run as a background service for the App services like Web App, API Apps and mobile Apps|
An Azure function is a code triggered by an event whereas an Azure Logic app is a workflow triggered by an event.
Azure Logic App can define a workflow at ease consuming a range of APIs as connectors. These connectors will perform series of actions defined in the workflow. Like Azure Logic Apps, durable Azure Functions can also be used to define workflow in code structure.
|Azure Functions||Azure Logic Apps|
|Trigger||Azure Functions can be triggered with the configured trigger like HTTPTrigger, TimerTrigger, QueueTrigger and more||Azure Logic Apps can be triggered with the API as connectors. It can also have multiple triggers in a workflow.|
|Defining Workflow||Workflow in Azure Functions can be defined using Azure Durable Function. It consists of Orchestrator Function that has the workflow defined with Several Activity Functions||Workflow on Azure Logic Apps can be defined with Logic App designer using various APIs as Connector.|
|Monitoring||Azure Functions can be monitored using Application Insights and Azure Monitor||Azure Logic Apps can be monitored using Log Analytics and Azure Monitor|
|Serverless360 can monitor both Azure Function Apps and Logic Apps|
Below is the detailed comparison on Azure Functions vs Logic Apps:
Azure Functions are the individual functions created in a Function App. Every Function can be invoked using the configured trigger. Azure portal provides the capabilities to create, 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, portal offers solutions like Application insights for live status monitoring through the invocation logs. Functions in the Function App can be monitored based on the app metrics.
Azure Functions runtimes versions are related to the major version of .NET. Below are the Azure Functions runtime version with equivalent .NET version:
|Runtime Version||Availability||.NET Version|
|3.x||Preview||.NET Core 3.x|
|2.x||GA||.NET Core 2.x|
|1.x||GA||.NET Framework 4.6|
GA – Generally Available
Azure Function 2.x is Generally available and 1.x is in the maintenance mode. Migrating from 1.x to later version is simple and straight forward which can be done from the Azure portal itself.
For any Azure Functions, a single Function execution has a maximum of 5 minutes by default 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 Function supports multiple languages and it is based on the Runtime versions.
Azure Functions can be called when triggered by the events from other services. Being event driven, the application platform has capabilities to implement code triggered by events occurring in any third-party service or on-premise system.
Azure Functions provides templates to get you started with key scenarios, including the following:
With Azure Function Proxies, user can have a >unified API endpoint for all the Azure Functions consumed by external resources. It is simple to create a proxy URL by only defining the backend URL and HTTP Method. It is also possible to modify the requests and responses of the Proxy. The advanced configurations are also available.
Below is a good read on Azure Function Proxies:
With Slots, Azure Functions can run in different instances. The Different environment of Functions can be exposed publicly by the API provided by the slots. When the need is to maintain the Functions by different environment like Production, Development and Staging, Slots will be the choice. An instance will be mapped with the Production environment and It can be swapped on Demand. Swapping can be done either through the portal or Azure CLI.
Create Azure Functions in Azure Portal:
To Create Azure Functions in Visual Studio:
After creating the Azure Functions in Visual studio, publishing it will be even more easy.
To Publish the Azure Functions from Visual studio:
Some of the highlighted differences between both the versions of Azure Functions are highlighted in the picture,
Previously in Azure Functions 1.0, there were a lot of native bindings available, so the runtime had to be changed in order to make changes to them (Bindings), but in Azure Functions 2.0, the runtime will be developed separately (Version independent) to get more clarity on the extensibility model.
For More details, refer the blog on Azure Functions Internals.
Azure Function App pricing is based on Execution time and Total Executions. It also includes monthly free grant of 1 million requests and 4,00,000 GB-s of resource consumption per month.
With Azure Function Premium plan, user can get the enhanced performance. It is billed based on vCPU-s and GB-s.
There are exhaustive set of metrics of the Azure Function Apps which can be monitored to detect the performance, availability and reliability of Azure Functions. Below is the detailed list of metrics and their descriptions:
|Metric Name||Description||Monitoring Perspective|
|Average Response Time||The Average time taken for a response from the Function App
Dimension: Entity Name
|Average Memory working set||Average memory consumed by a Function App execution
Dimension: Entity Name
|Function Execution count||Number of Functions executions
Dimension: Entity Name
|Thread Count||Number of threads allocated for a function execution
Dimension: Entity Name
|Http 1xx||Number of Information responses
Dimension: Entity Name
|Http 2xx||Number of Successful responses
Dimension: Entity Name
|Http 3xx||Number of Redirection responses
Dimension: Entity Name
|Http 4xx||Number of Error responses
Dimension: Entity Name
|Http Server Error||Number of Server Error responses
Unit: Count Aggregation: Total
Dimension: Entity Name
For Better understanding of the Azure Functions, let’s take a simple Order Processing scenario of an E-Commerce application.
Below is the workflow:
In the Above scenario, there are two Functions used. One validates the product type whether it is a book or other products. And other Function retrieves the price of the book. Both the Functions are used for the validation operation that can be triggered through the Logic Apps.
Azure Functions are best suited for smaller apps have events that can work independently of other websites. Some of the common azure functions are sending emails, starting backup, order processing, task scheduling such as database cleanup, sending notifications, messages, and IoT data processing.
Being as a cloud service, Azure function has lot of advantages. Some of those advantages are highlighted below:
Pay as you go model- Azure Functions comes in the Pay as you go model. User can pay only for what they use. For Azure functions, cost is based on the Number of Executions per month. Cost structure of Azure Functions are mentioned above in the Pricing Section.
Supports variety of Languages- Azure Function supports major languages like Java, C#, F#, Python and more. Refer above to know more about Azure Functions supported languages.
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 as a trigger-based service, it run on demand. Refer the Trigger section above to know more about the available triggers.
Functions provides serverless compute for Azure. You can use Functions to build web APIs, respond to database changes, process IoT streams, manage message queues, and more. As Azure Functions can be connected to many other applications running in On-prem or on Cloud, making it a Serverless offering provides better scalability and efficiency.
Azure Durable Functions is an extension of Azure Function that is used to write Stateful Functions. It consists of Orchestrator function and entity functions that can be defined as a workflow. As a state-based services, it enables checkpoint and restarts from it.
The Orchestrator Client is the starting point of the Azure Durable Function. It calls the orchestrator Function which defines the workflow of the orchestration.
This Orchestrator Function has the workflow of the orchestration. This workflow consists of several pieces of code as Functions named Activity. It may also call other orchestration functions as well. This Orchestrator function is called by an Orchestrator Client.
Activity Functions are the basic unit of work in a durable function. Each Activity performs an asynchronous task. Activity Function supports all languages that the Azure Function supports. But Orchestration Function can support only C#.
Below are the articles that speaks about Azure Durable Function and its patterns:
Application Insights is an Application Performance Management (APM) service for monitoring Application performance and latency. With this tool, user can detect anomalies and diagnose issues. It can be used in various platforms like .NET, Node.js, Java EE, python(preview) and more. It has various capabilities like Smart Detection, API Testing, Failure Detection, Application Map, Live Metrics Stream, Analytics and more. It is also having Integration with Alerts, Power BI, Visual Studio, Rest API and Continuous Export.
Azure Monitor can be used to monitor the Azure services in various perspectives. It maximizes the availability and performance of the application or service. This Azure Monitor offers several services like Application Insights, Log Analytics, Alerts and Dashboards. It is also having integration with Power BI, Event Hubs, Logic Apps and API.
With Metrics Explorer, user can detect the performance, latency of the Application 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 is tool used to manage Azure Monitor queries. With Log Analytics, user can perform monitoring and diagnostics logging for Azure Logic Apps. User can also query the log for efficient debugging.
With Alerts in Azure Monitor, user can get the alert report when there is a violation. These Alerts are also based on the metrics that was configured while creating it. Single Alert can only monitor the single Entity based on the couple of metrics configured.
Below is the comparison on Serverless360 vs Azure Monitor:
Azure Functions are billed by pay as you go approach. But for the initial start, Azure provides you free bandwidth of 5GB. Above that will be charged as usage. However, Azure Functions can be used with Azure IoT Edge at no charge.
Azure Function Apps can solve huge business challenges but managing and monitoring them in Azure Portal is quite challenging. So Here comes Serverless360 that offers managing and monitoring the Azure resources in Application context. With Serverless360, Azure Functions can be managed, monitored and analyzed in various perspectives.
Though Application Insights have various features for App services, it is not possible to monitor other services like Azure Service bus, Logic Apps etc., It is also not possible to monitor the Azure entities in application context.
Whereas with Serverless360, it is possible to monitor the entities at the context of the business application and user can also get the consolidated monitoring report that reveals the health status of all the entities with the root cause of error. Serverless360 also provides intelligent automations to ensure the production environment in Enabled state.
With BAM in Serverless360, user can perform end-to-end distributed tracing on the Business processes (i.e., workflow of Logic Apps, Azure Durable Functions or Custom Web Application). Find below the detailed analysis on Serverless360 and Application Insights comparison
Managing Azure Functions in Serverless360 is simple and Straight forward. User can straight away associate the Azure Function to the appropriate Composite Application that represents the business application. Along with the Application level management and monitoring, user can also leverage the integrated tooling mentioned below:
In Serverless360, User can perform remote actions like Start/ Stop the Function App or Functions and Restart the Function App. Being in Serverless360 itself, user does not need to switch between Azure portal and Serverless360 for these frequently carried out actions.
From Serverless360, user can investigate on the issue in the Azure Function Execution by viewing invocation logs. It also provides the success count, Error count and filtering for faster retrieval of the Azure Function Execution. The Invocation Logs can be retrieved for both 1.x and 2.x versions.
User can also get to view the properties like App state, Region, Operating System and Hosts of the Azure Function App and properties like type, direction and methods of Azure Functions.
Though Azure provides monitoring solutions like Azure monitor and Application Insights, user cannot monitor multiple entities with various metrics. Whereas, with monitors in Serverless360, it is possible to monitor multiple entities based on metrics in Application level. Below are the types of monitors with which user can monitor Azure services in various perspectives.
Consider when the user needs to get the alert report of health status of all the entities in the business application, every two hours or at the end of day, there is a need for a specialized monitor. With Status monitor in Serverless360, user can monitor the state of an entity that gives the health report of the Azure services. For this monitor, user can configure the number days in a week and number of hours in a day to get the alert report at the configured time.
There would be a need to monitor the HTTP Responses of Azure Functions like Internal server errors (500), Successful responses (200) and so on. With the help of Data monitor in Serverless360, user can monitor Azure Function App on HTTP responses and on other extensive set of metrics.
It is also possible to monitor the number of function executions, Data in and Out, Average response time and more.
Consider a scenario where a DevOps engineer needs to know the status of the entities only when there is a violation. With the Threshold Monitor in Serverless360, user will get the alert when the violation persists beyond defined minutes. Threshold monitor also provides the option to auto correct the state of the entities with which Serverless360 ensures the state of the Azure services are as expected.
Consider a developer wants to get notified whenever there is a failure in the invocation of Azure Functions. With the help of Watch Monitor in Serverless360, user can have an eye on the Azure Functions for failure in their execution. It will send the alert report with the error reason whenever there is a failure in the Azure Function execution.
Consider a business support person wants to find the errors/exceptions in their business process to correct and reprocess them. With the help of BAM in Serverless360, user can perform End to End tracking on the business process of Azure Serverless Applications that consists of Azure Functions.
Check Azure Functions monitoring feature page for more insights.
Hope this article threw light on all necessary concepts on Azure Functions. This will not be complete without mentioning the Serverless Notes. It is a community initiative by Serverless360 to bring as much relevant and valuable content for the best use of the developers and architects.
Serverless Notes is a knowledge base that covers serverless best practices, tips, latest announcements etc. contributed by technology enthusiasts and collected from various resources. This site is structured very much like a firsthand reference material for anybody working with Azure Serverless.