What a Heck Is an Azure Function?

Rafael AS Martins
Geek Culture
Published in
6 min readFeb 25, 2021
Azure functions

As you probably already noticed, the cloud is a hot and recurrent topic in today’s conversations.

We repeatedly hear buzz words like AWS Lambdas, Kubernetes, Azure functions, and much more. It’s incredible and sometimes stressful, to see and realize the enormous number of functionalities these companies supply to their clients.

As software engineers, it’s a requirement to get everything up to speed and keep up with the market speed and innovation, so we don’t lose the train.

In today’s article, I will mainly focus on the Azure functions:

  • What a hack is an Azure function?
  • Is it easy to create and use them?
  • Conclusion

# What a hack is an Azure function?

Microsoft Azure

Azure functions are a well-known service, supplied by Microsoft Azure cloud services.

We can look at them as small pieces of code that you can run in the cloud without worrying about infrastructure matters, also known as serverless.

Serverless is a way to describe the services, practices, and strategies that enable you to build more agile applications so you can innovate and respond to change faster. With serverless computing, infrastructure management tasks like capacity provisioning and patching are handled by AWS, so you can focus on only writing code that serves your customers. Serverless services like AWS Lambda come with automatic scaling, built-in high availability, and a pay-for-value billing model.

Amazon AWS

Such services have the goal of helping you focus on the domain problem you’re trying to solve. We may not notice, but in time, we usually tend to lose focus on the domain problem we’re trying to solve for all other sorts of, like infrastructure.

You don’t even need to learn a new coding language to code them. It supports a ton of languages, like Java, C#, Python, JavaScript, even Powershell if you feel like it.

Your services will automatically scale (vertically or horizontally). Once again, you solve your domain problem while Azure solves the infrastructure ones, and don’t worry, you will only pay for the time the code runs. While it’s idle, you don’t get charged.

You may be wondering, how do these functions get called and executed?

That’s an interesting question. There’s also a ton of possible solutions available to your problem.

There’s something called triggers and bindings:

  • Triggers — Direction is always in. Defines how a function gets executed. A function must have exactly only one trigger.
  • Bindings — Direction may be in and out. A binding is a connection to data within your function.

Some examples of actions that may trigger your functions:

  • HTTPTrigger — Gets executed whenever a request has been sent through the HTTP protocol.
  • CosmosDBTrigger — Gets executed whenever a document is inserted or updated within the NoSQL database;
  • TimerTrigger — According to a specified schedule.

Other examples can be found in Azure’s documentation.

Alternatives

Azure functions may be your best choice if you’re currently looking for some administration simplicity and coding flexibility.

# Is it easy to create and use them?

Photo by Hello I'm Nik 🎞 on Unsplash

If they simplify our administration and make our code way more flexible, why would they be hard to set up?

That crossed my mind in the beginning while learning Azure’s platform organization. After getting used to it, it was as simple as clicking a few buttons.

I will now explain how you can easily create and have an Azure function solution up and running in just a few steps.

  1. By accessing the Azure function official page, click on the “start free” button and set up your account based on the 14 days free tier.
Start Free

2. Login into the Azure portal. You should be able to see the main page already with some suggested services to use.

Azure portal main page

3. Click at Create a Resource and select Function App.

Function App

4. Fulfill the form with the following data:

  • Subscription — Select the subscription you want to use for billing purposes. We are currently using a free tier, and there’s no billing associated, select the first one that comes up.
  • Resource Group — A resource group is like a logical collection of virtual machines or even functions. Create one that will help you logically organize your functions.
  • Function App Name — This name should be unique, as it will be used to generate a unique URL that will identify your function and make it available.
  • Publish — Select code.
  • Runtime stack — Select the language stack you will be using for writing your function. In the current example, we will use Node.JS.
  • Version — Stack version, usually gets auto-filled.
  • Region — Select a region near to your location. It will be the place where your function will get stored.
Create Function App Form

5. Click on “Review + Create” and after validation, click on “Create”. It will show the function overview page. Click on “Go to resource”.

Overview page

6. Within the Function App, you can have several functions. Let’s add our first one. Click on the left side “Functions” option and then “+ Add”.

Functions page

7. As described in the previous section, we need to define what action will trigger our function. Azure already gives us several templates we can use.

To keep the example simple, let’s choose the HTTPTrigger template.

After selecting the template, define which name you want to give to it and which authentication rights you want your function to have.

  • Function — Only functions that share the same Function App;
  • Anonymous — No authentication is required and any valid HTTP request passes;
  • Admin — Authorization level that requires a host key for authorization.

To submit all the selected decisions, click on “Add”.

7. After creating the function, you will be able to see the admin page. In it, you can monitor all requests and time executions, and most important, code your domain logic.

Code + Test

8. To test your function availability, you can click on the “Get Function URL” and make a request to the given link. You should get a similar response.

HTTP GET Request

And that’s it, your first Azure function has been created and now available to everyone!

# Conclusion

As you can see, easy and clean!

The best Azure function sibling you can find on the market is the AWS lambda. They’re similar in concept terms, a change between suppliers should be straightforward as you catch the main concepts.

Have a look at some of my previous articles, who knows, probably you are someone who likes simplicity and flexibility as I.

Let’s chat on Linkedin.

--

--

Rafael AS Martins
Geek Culture

As a software engineer, creating good and reliable solutions is my everyday goal. Within my articles, I try to express all the excitement and passion around it!