Azure Function and its purpose

Azure Function and its purpose

Over the past few months, I’ve been working with Azure Functions and have also encountered them briefly while studying for the AZ-900 and AZ-204 certifications. In this article, I’ll explain what Azure Functions are, how they work, and where they fit into enterprise solutions.

What is an azure function and how does it work?

Azure Functions is a serverless compute service that enables you to run small pieces of code called "functions" without worrying about infrastructure or managing servers. These functions are event-driven, meaning they are executed in response to triggers such as HTTP requests, timer schedules, message queues, or blob uploads.

You can write Azure Functions in multiple languages including C#, JavaScript, F#, Java, and Python.

What makes Azure Functions powerful is their simplicity and scalability; you only write the logic, and Azure handles the scaling, hosting, and availability behind the scenes.

Triggers and Bindings

Azure Functions rely on triggers and bindings:

  • Triggers define how the function is invoked. For example, an HTTP trigger runs the function when an HTTP request is received.
  • Bindings connect the function to external services (like Azure Storage, Cosmos DB, or Service Bus) without you needing to write integration code manually.

For instance, you could set up a function that’s triggered on a schedule and writes data directly into an Azure Cosmos DB collection - no boilerplate code needed.

How are Azure Functions used?

Azure Functions are designed to operate independently. They are best suited for small, decoupled tasks, not large monolithic systems.

Common Use Cases:

  • Sending automated emails
  • Processing background jobs
  • Executing scheduled tasks
  • Responding to webhooks
  • Data ingestion and transformation

Because functions are stateless and event-driven, they excel at handling these lightweight, reactive workloads.

Azure function in enterprise solutions

In enterprise applications, Azure Functions are often used as microservices or middleware, gluing together other services, handling asynchronous operations, or triggering downstream workflows. They are a great fit for event-driven architectures, especially when combined with services like Azure Event Grid, Service Bus, or Logic Apps.

Creating Azure Functions: Portal

To create and deploy Azure Functions, you’ll need an Azure account with a valid subscription.

Steps via Azure Portal:

  1. Go to the Azure Portal and create a resource → choose Function App.
  2. Choose your hosting plan:
    • Consumption Plan (pay-per-execution, auto-scales)
    • Premium Plan (dedicated compute, faster cold start)
    • Flexible Consumption (Preview) for isolated workloads
  3. Choose a region, OS, and runtime stack.
  4. Once deployed, you can create a function inside the app using the portal.

Visual Walkthrough: Creating a Function App in the Azure Portal

Step 1: Open Azure Portal and Start Creating a Function App

Step 2: Select a Hosting Plan - I have selected Consumption since I am on a free sub

Step 3: Set the Function App name, select OS, runtime stack, and version.

Note: If you wish to create azure functions within the Azure Portal, then selecting In-Process Model would allow you to do that.

Step 4: Once deployed, Azure shows a confirmation screen where you can click "Go to resource" to proceed.

Step 5: Create a New Function in Azure Portal

Step 6: Choose a Trigger Type; We will be working on HTTP trigger in this example

Step 7: Set Authorization Level

Each Authorization level differs.

Anonymous level - requires no authentication.

Function level - require a function specific api key to be included in the request. We need to set it through function app settings

Admin level - used for administrative level and requires a master key. It grants access to all functions within the app.

In this example, I will be going with Anonymous level.

After creation, we will have this... A sample code provided to us.

Let us understand this HTTP trigger sample code

After setting up your function and selecting the HTTP trigger template with an Anonymous authorization level, Azure automatically scaffolds a sample function for you. Below is the generated code for an HTTP-triggered Azure Function in C#:

#r "Newtonsoft.Json"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");

    string name = req.Query["name"];

    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
    dynamic data = JsonConvert.DeserializeObject(requestBody);
    name = name ?? data?.name;

    string responseMessage = string.IsNullOrEmpty(name)
        ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);
}

What This Code Does:

  • The function listens for an HTTP request.
  • It checks for a "name" parameter in the query string or request body.
  • If a name is found, it returns a greeting message.
  • If not, it provides a default message.
https://fztestfunc-c0d4enccbzdxardn.canadacentral-01.azurewebsites.net/api/FzTestHttpTrigger?name=fz3hra

When name is passed, the output will be as follows:

This was for creating a function within Azure Portal.

Alternatively, you can develop and publish functions locally using:

  • Visual Studio / VS Code
  • CMD Line - Azure Functions Core Tools

And... That's it for a brief on Azure functions. I hope this article helped you.

If you have any questions, insights, or tips from your own experience, feel free to share them in the comments, let’s learn and grow together!


References

Azure Functions overview
Learn how you can use Azure Functions to build robust serverless apps without writing extra code.
Triggers and bindings in Azure Functions
Learn to use triggers and bindings to connect your Azure Function to online events and cloud-based services.

About Me

I am Zaahra, a Google Women Techmakers Ambassador who enjoy mentoring people and writing about technical contents that might help people in their developer journey. I also enjoy building stuffs to solve real life problems.

To reach me:

LinkedIn: https://www.linkedin.com/in/faatimah-iz-zaahra-m-0670881a1/

X (previously Twitter): _fz3hra

GitHub: https://github.com/fz3hra

Cheers,

Umme Faatimah-Iz-Zaahra Mujore | Google Women TechMakers Ambassador | Software Engineer