Microsoft Azure Functions
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 and metrics of Function App entities, tools available to manage and monitor Azure Function Apps and much more. This guide also justifies how Serverless360 turns out to be the best tool to manage and monitor the Azure Function Apps. This guide will answer all your questions related to the Azure Function Apps and provide useful links to explore further. This guide will be continuously revamped to stay up-to-date
Explore out of box capabilities of Serverless360 for Azure FunctionsBook a Demo
We promise to never spam or give away your email.
Azure Function Overview
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.
What is Azure Function?
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 Functions vs Web Jobs
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|
Azure Functions Vs Logic 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:
- When to use Azure Logic Apps and Azure Functions with some real-time comparison by Steef-Jan Wiggers
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.
Azure Function supports multiple languages and it is based on the Runtime versions.
Azure Functions can be 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:
- HTTPTrigger-Trigger the execution of your code by using an HTTP request.
- TimerTrigger– Execute clean up or other batch tasks on a predefined schedule.
- CosmosDBTrigger-Process Azure Cosmos DB documents when they are added or updated in collections in a NoSQL database.
- BlobTrigger-Process Azure Storage blobs when they are added to containers. You might use this function for image resizing.
- QueueTrigger-Respond to messages as they arrive in an Azure Storage queue.
- EventGridTrigger-Respond to events delivered to a subscription in Azure Event Grid. Supports a subscription-based model for receiving events, which includes filtering. A good solution for building event-based architectures.
- EventHubTrigger-Respond to events delivered to an Azure Event Hub. Particularly useful in application instrumentation, user experience or workflow processing, and internet-of-things (IoT) scenarios.
- ServiceBusQueueTrigger-Connect your code to other Azure services or on-premises services by listening to message queues.
- ServiceBusTopicTrigger-Connect your code to other Azure services or on-premises services by subscribing to topics.
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.
Provision Azure Function
Create Azure Functions in Azure Portal:
- Click on Create a resource, select on Azure Functions App in Compute section and Click Create
- Provide the necessary details and create it
To Create Azure Functions in Visual Studio:
- Select File -> New Project. Select Azure Function project.
- Provide the necessary details like Name, path, Function App version and Trigger option. Click Create
After creating the Azure Functions in Visual studio, publishing it will be even more easy.
To Publish the Azure Functions from Visual studio:
- Right Click on the Project Name, Select Publish .
- Provide the details like Resource group name, storage account and more. After this process, the profile will be created and ready to publish
- Click Publish. Now the Azure functions can be accessed in read- only mode in the Azure Portal.
Compare 1.x vs 2.x
Azure Functions 1.0 challenges
- Need for additional language support, e.g. Java, Python, PowerShell
- Only able to host on Windows
- No support for development on Mac and Linux
- Assembly probing and binding issues for .NET developers
- Performance issues on a range of scenarios/languages
- Lack of UX guidance to production success
What’s new in Azure Functions 2.0?
- New Functions quick start by selected programming language
- Updated runtime built on .NET Core 2.1 (supported .NET Framework on the previous version)
- Deployment: Run code from a package
- .Net Function loading changes
- Tooling Update: Visual Studio, CLI and VS Code
- Consumption-based SLA
Key differences between Azure Functions 1.0 and 2.0
Some of the highlighted differences between both the versions of Azure Functions are highlighted in the picture,
Bindings and Integration
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.
- Execution Time – $0.000016/GB-s
- Total Executions – $0.20 per million executions
With Azure Function Premium plan, user can get the enhanced performance. It is billed based on vCPU-s and GB-s.
- vCPU Duration – $0.173 vCPU/hour
- Memory Duration – $0.0123 GB/hour
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
Real time scenario
For Better understanding of the Azure Functions, let’s take a simple Order Processing scenario of an E-Commerce application.
Below is the workflow:
- Customer places an order in the eCommerce website
- The website submits a new order message to the Service Bus Queue
- Azure Function filters all the orders for the focused item (Books) to push them to a Topic
- The other orders will be sent to a Service Bus Queue
- The Book order will be further be segregated based on order copy type using Topic Subscription Rules
- The Azure function will retrieve the price of the ordered Book from the storage table and compute the order price
- An invoice will be created based on the computed price returned by the function
- The notification will be sent to the customer with Product details and invoice through Microsoft Outlook
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 Advantages
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.
Azure Durable Functions
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 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.
Serverless360 Vs Application Insights
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 tracking 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
Manage Azure Functions in Serverless360
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:
Start/Stop the Functions
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.
View Invocation Logs
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.
View Properties of the Azure Functions
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.
Monitor Azure Functions in Serverless360
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.
Business Activity Monitoring
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.
Track Azure Durable Functions using BAM
- End to End Tracking of Business Process
- Tracking Custom Properties
- Error Detection
- Reprocessing Failed Business process
- Easy Instrumentation
Find all features offered by Serverless360 for Azure Function Apps here.
How to stay up to date on Azure Functions?
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.