• Articles
  • Tutorials
  • Interview Questions

What is Microsoft Azure Functions?

What is Microsoft Azure Functions?

Table of content

Show More

Before moving ahead, have a look at our Azure tutorial prepared by industry experts:

Video Thumbnail

Introduction to Azure Functions

Azure Functions are serverless solutions that allow you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running. Azure Functions provides a feature called ‘compute on demand’. This is for the system to respond to a series of events.

This is done in two ways:

  • Azure Functions allows the users to implement their logic in particular pieces of code. These are known as “functions”. Various functions run at various times of response.
  • When the requests increase, Azure Functions create as many resources and function instances as required as per the need. Again, when the requests decrease, the extra resources and function instances are deleted automatically.

List of Azure Functions

Task required to be doneWhat can be done
Build a web APIUse HTTP trigger
Process file uploadsRun code when blob storage is updated
Serverless workflowUse series of functions
Database changes responseRun code when Azure Cosmos DB is updated
Run schedule tasksRun code at a particular time
Message Queue SystemUse Queue Storage, Service Bus, Event Hubs
IoT data streamsProcess data from IoT devices
Process real-time dataUse Functions and SignalR

Durable Functions in Azure Functions

Durable Functions are extensions of Azure Functions that lets you write stateful functions in a serverless compute environment. Durable functions help in defining stateful workflows and stateful entities using the Azure Functions programming model. Durable functions only support the following languages currently:

  • C#: Supports both pre-compiled libraries and C# script.
  • Javascript: Supports only version 2.x for the Azure Functions runtime.
  • Python: Requires 2.3.1 version or above.
  • F#: Supports both pre-compiled libraries and F# script. Only for the 1.x version.
  • Powershell:Supported only for the 3.x version of the Azure Functions runtime.

Cloud Computing EPGC IITR iHUB

Comparisons

Let us compare the automation services to know what will suit best as our requirements:

Microsoft Power Automate VS Azure Logic Apps

Power AutomateLogic Apps
The users are office workers, business users, SharePoint administratorsThe users usually are professional integrators and developers, IT professionals
Used for self-service scenariosUsed in case of advanced integrations
The design tools for mobile and browser are UI onlyIn browser and visual code, code views are available
Design and test are conducted in non-production environments and promoted to production when readyAzure DevOps solely manages source control, testing, support, automation, and manageability in Azure Resource Manager
Admin can manage Power Automate environments and data loss prevention (DLP) policies, track licensing is done in Admin centerAdmin can manage resource groups, connections, access management, and logging is done in Azure portal
For security, Microsoft 365 security audit logs, DLP, encryption at rest for sensitive data are presentThe security assurance of Azure has Azure security, Azure Security Center , and audit logs

Durable Functions VS Logic Apps

Durable FunctionsLogic Apps
Code is developed firstDesign is developed first
For connection, it has many built-in bindingsHas a large collection of collectors
Every activity is an Azure Function. Codes can be written for custom functionsContains a large collection of ready-made actions
Monitoring is done by Azure Application InsightsMonitoring is done through the Azure portal and Azure Monitor Logs
REST API and Visual Studio manage the thingsAzure portal, REST API, PowerShell, Visual Studio together manage the things
This can run locally in the cloudThis only runs in the cloud

Benefits of using Azure Functions

  • Azure Functions provide a very simplified and user-friendly development environment
  • A separate server is not necessary to maintain the Azure Functions
  • Azure Functions help to break down very big architectures into smaller codes
  • Azure Functions provide independent scaling

Get 100% Hike!

Master Most in Demand Skills Now!

Consumption Plan Costs of Azure Functions

The execution cost of a single function is measured in GB-seconds. This is done by combining memory usage and the particular execution time. Function runtime and Memory consumption by the function are both directly proportional to the cost.

Suppose that the function consumes 1 GB in 2 seconds, then the execution cost would be

1GB * 2s = 2GB-s

Memory usage is rounded up to the nearest 128 MB bucket.

While using functions related to HTTP, if an error occurs before the function code is executed, the charges are not applied. Similarly, status codes in 500s are not counted if they occur before the execution of the function. However, if a status code in 500s occurs after the function has started to execute, it will be counted.

When estimating the overall cost of running your functions in any plan, remember that the Functions runtime uses several other Azure services. When calculating pricing for Azure function apps, any triggers and bindings you have that integrate with other Azure services require you to create and pay for those additional services.

Each function app requires that you have an associated General Purpose Azure Storage account. This account is used internally by the Functions runtime, but you can also use it for Storage triggers and bindings. If you don’t have a storage account, one is created for you when the Azure function app is created.

Application Insights

Functions rely on this for high-performance monitoring. A free grant of telemetry data is included every month.

Network Bandwidth

We do not need to pay for data transfer between Azure services in the same region. However, we might incur costs for outbound data transfers to another region or outside of Azure.

Azure Functions Tutorial

1. Goto the search bar and search for function App and open it

search bar

2. Click on create to create a new function app.

new function app

3. Fill in the details and proceed to click on Review + Create

create a new function

4. If you are satisfied with the review, click on Create at the bottom

review

5. Wait for a minute or two until the function app gets created. You can check the status by clicking on the notification icon (bell icon).

notification icon

6. Once the status turns to green, that is, a tick mark as shown, click on the go-to resource to proceed. This will take us inside the function app.

function app

7. This is how the created function app will look. Check the left column for Functions and click to proceed.

click to proceed

8. After this, click on add, to create a new function.

click on add

9. Choose the Develop in portal option and choose the HTTP trigger as the template and click on add below.

HTTP trigger

10. Wait for the function to be created and click on Code + Test.

Code + Test

11. After this, click on the Get function URL.

function URL

12. Paste the URL on the browser and check if it is loading. If not, recheck the process.

Paste the URL

13. It asks to pass a name as a string.

At the end of the URL, type &name=”AbC”

AbC is just an example name, anything can be used in place of that.

Like it can be seen in the given picture, the name gets reflected on the page. This is done by the HTTP trigger function which we created.

HTTP trigger function

Conclusion

Azure functions as a serverless, compute-on-demand, lightweight, and independent app. We can create an entire web application and much other automation with different triggers and output bindings. Multiple language options like Python, C#, JavaScript, etc. make functions accessible to any developer to create their serverless solution.

Course Schedule

Name Date Details
Azure Training 23 Nov 2024(Sat-Sun) Weekend Batch View Details
30 Nov 2024(Sat-Sun) Weekend Batch
07 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Senior Cloud Computing Associate

Rupinder is a distinguished Cloud Computing & DevOps associate with architect-level AWS, Azure, and GCP certifications. He has extensive experience in Cloud Architecture, Deployment and optimization, Cloud Security, and more. He advocates for knowledge sharing and in his free time trains and mentors working professionals who are interested in the Cloud & DevOps domain.