What is Azure Functions?

Azure Functions is a solution for easily executing small fragments of code or “functions” in the cloud. It takes the basic concepts of the already known WebJobs and develops them in interesting ways.

Azure Functions presents us with a host of new triggers to be able to run it. These triggers include: Cosmos DB, Event Hub and WebHooks.

Advantages 

  • We can code everything we need for the problem/action that we want to execute without worrying about the app or the infrastructure.
  • It makes development more productive.
  • Change in the payment model regarding WebJobs. Azure Functions has two payment models, as well as it being able to be included in an existing payment model as an App Service. You can also pay only for the time that this function is running.
  • We can code in different programming languages, like C#, F#, Node.js, Java or PHP.
  • It allows us to develop serverless applications in Microsoft Azure.
    https://portal.azure.com/


Characteristics 

Here are some of the most important characteristics that we can find in Azure Functions:

  • Code in different programming languages: C#, F#, JavaScript etc…
  • Only pay for the time that Azure Functions is running.
  • Recognises both Nuget and NPM.
  • Allows you to code in both the Azure portal as well as in our application and then integrate it configuring continuous integration in Azure.

Execution triggers 

These are the triggers that are currently available for running Azure Functions:

HTTP Trigger: We run the Azure Function code through a HHTP request. Example 

TimerTrigger: We run the azure Function code through a timer. Example 

CosmosDBTrigger: We run Azure Function code when we add or update collections in a database. Example 

BlobTrigger: We run the function when we add new blobs to the Azure Storage containers.

QueueTrigger: We run the code of a function as they arrive at an Azure Storage queue.

EventHubTrigger: Responds to events in Azure Event Hub.

Creation of an Azure Function

Steps to follow for the creation of a new Azure Function:

1. We enter the Azure Portal https://account.windowsazure.de/Home/Index and log in. This is the dashboard you’ll see once you have logged in:2. Choose the option “Create a resource” and a browser will appear in which we will put “Function App”, where we select the option that is marked in the image.



3. The following menu will appear:

  1. App name: Name of App Function.
  2. Subscription: Subscription to which our Azure account is associated.
  3. Resource group: groups of Azure resources, we can create a new one or use one that already exists.
  4. OS: Windows/Linux operating system.
  5. Hosting Plan: We can select the payment model when the Azure Function is running, or rather use a payment plan that already exists in an already created App service.
  6. Location: Location of App Function.
  7. Runtime Stack: We can select .NET, Javascript or Java.
  8. Storage: Container that uses Azure Functions. We can create a new one or use an already existing one.

 

Once we have created our App Function, we proceed to create our Azure Function with any of the Triggers available for execution:

  • Name of the App Function that we have previously created.
  • Button for creating a new Azure Function.
  • All the triggers that we have for creating our Azure Function.
  • Already created Azure Functions.

This is what our already created Azure Function would look like. In the example, we can see that it’s an Azure Function with a timer trigger configured with a CRON expression, example:

0 */1 * * * *

 This will execute the code of our function every minute, in this case it will show us in the log of the function day and the time at the moment that the function has been executed.


Conclusion 

To sum up, Azure Functions offers a solution that allows us to manage operations on a large scale at a low cost, and I am therefore completely convinced that it will soon substitute the traditional storage methods, since the non-intervention management approach reduces the demands of operations, while keeping costs low.

Interested in learning more about Azure functions? Have a look here where we look at Azure functions vs. Azure Webjobs! It’s worth a read 😉

Written by: Ivan Roldan