Wednesday, June 2, 2021

Azure Functions

Azure Functions allows a piece of code to be deployed and executed without needing server infrastructure, web server, or any configurations. In addition, azure functions can be written in multiple languages such as C#, Java, JavaScript, TypeScript, and Python.

Here are some key concepts related to Azure Functions:

  1. Trigger: A trigger is what causes a function to run. Azure Functions support various triggers, such as HTTP requests, timers, messages from a message queue (like Azure Service Bus or Azure Queue Storage), blob storage events, and more.

  2. Bindings: Bindings are a way to connect input and output data to a function. They simplify the code needed to interact with other Azure services. For example, you can use input bindings to read data from Azure Storage, and output bindings to write data back to it without having to write code for these operations explicitly.

  3. Language Support: Azure Functions supports multiple programming languages, including C#, JavaScript, Python, and more. You can choose the language that best fits your needs and skills.

  4. Durable Functions: This is an extension of Azure Functions that lets you write stateful functions in a serverless environment. It's particularly useful for workflows and scenarios where you need to manage state across multiple function invocations.

  5. Development Tools: You can develop Azure Functions using the Azure Portal, Visual Studio, or other supported IDEs. Azure Functions Core Tools is a set of command-line tools that facilitates local development and testing.

  6. Pricing: Azure Functions pricing is based on the actual execution of functions and the resources consumed by them. You pay only for the compute resources consumed during execution.

To create an Azure Function, you typically follow these steps:

  1. Create a Function App: This is a container for your functions. It provides a way to manage and deploy related functions together.

  2. Create a Function: Once you have a Function App, you can add individual functions to it. Each function can have its own trigger and bindings.

  3. Configure and Test: Configure the function with any necessary settings, including connection strings and other environment variables. Test the function locally before deploying it to Azure.

  4. Deploy: Deploy your function to Azure using the deployment options provided by your development environment.

  5. Monitor and Debug: Azure Functions integrates with Azure Monitor, allowing you to monitor the performance and health of your functions. You can also enable logging and diagnostics to aid in debugging.

Keep in mind that Azure Functions is just one part of the broader Azure ecosystem, and you can integrate functions with other Azure services to build powerful and scalable solutions.

When to use:

Let’s say, you have to send a birthday email to your customers. You’re an ASP.NET web developer. Instead of building a website in ASP.NET, deploy and hosting it on IIS, just for one feature, you can simply write an azure function and put your email login in the function and deploy it on azure cloud. The azure functions will direct connect to your data source, get your customers emails, and send them an email on a scheduled date and time.

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.

Why use Azure Functions

Here are some of the reasons why you should use azure functions. 

  1. Azure functions are lightweight and serverless.
  2. Azure functions are easier to write and deploy.
  3. Azure functions are fast to execute because there is no large application, startup time, initialization, and other events fired before the code is executed.
  4. Azure functions’ execution is triggered when an event is fired.
  5. Azure functions are compute-on-demand and that is scalable. When demand of execution increases, more resources are allocated automatically to the service and when requests fall, all extra resources and application instances drop off automatically.
  6. Azure functions support multiple programming languages including C#, F#, Java, JavaScript, TypeScript, and Python. You choose your choice of language.
  7. Azure functions do not need any infrastructure and have 0 maintenance.
  8. Azure function can be build, tested, and deployed in Azure portal using a browser.
  9. Azure functions are easy to upgrade and doesn’t affect other parts of the website.
  10. Azure functions use industry standard and can communicate with other APIs, databases, and libraries.

Reference: https://www.c-sharpcorner.com/https://www.serverless360.com/azure-functions


0 comments:

Post a Comment