#atom

Event-driven serverless compute service by Microsoft

Core Idea: Azure Functions is Microsoft's serverless compute service that enables running code on-demand without managing infrastructure, automatically scaling based on demand and charging only for compute resources used during execution.

Key Elements

// C# HTTP Trigger Function
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

public static class HttpExample
{
    [FunctionName("HttpExample")]
    public static IActionResult Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        log.LogInformation("C# HTTP trigger function processed a request.");

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

        string requestBody = new StreamReader(req.Body).ReadToEnd();
        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);
    }
}

Connections

References

  1. Microsoft Azure Functions Documentation (https://docs.microsoft.com/en-us/azure/azure-functions/)
  2. "Azure Functions Serverless Architecture" by Microsoft Azure

#azure #serverless #faas #microsoft #cloud-computing


Connections:


Sources: