MSDN Documentation

Introduction to Azure Functions

Azure Functions is a serverless compute service that enables you to run code on-demand without explicitly provisioning or managing infrastructure. With Azure Functions, you can build applications by connecting various services, orchestrating them with triggers and bindings.

What are Serverless and Functions?

The term "serverless" doesn't mean there are no servers; it means that the developers don't need to manage the underlying infrastructure. The cloud provider, in this case Microsoft Azure, handles all the provisioning, scaling, and maintenance of the servers. This allows developers to focus solely on writing their application code.

Azure Functions is Azure's implementation of serverless compute. It allows you to execute small pieces of code, called "functions," in response to events. These events can be anything from an HTTP request to a change in a database or a message arriving on a queue.

Key Concepts

  • Event-driven: Functions execute in response to triggers.
  • Scalable: Azure automatically scales your functions based on demand.
  • Cost-effective: You pay only for the compute time you consume.
  • Polyglot: Supports multiple programming languages (C#, JavaScript, Python, Java, PowerShell, and more).
  • Integrated: Seamless integration with other Azure services and third-party services.

When to Use Azure Functions?

Azure Functions is ideal for a wide range of use cases, including:

Core Components

Azure Functions are built around a few core concepts:

Example of a Simple HTTP Triggered Function

Here's a conceptual example of a JavaScript function that is triggered by an HTTP request:


module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');

    const name = (req.query.name || (req.body && req.body.name));
    const responseMessage = name
        ? 'Hello, ' + name + '!'
        : 'This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.';

    context.res = {
        status: 200,
        body: responseMessage
    };
};
            

Getting Started

To start building with Azure Functions, you'll typically need:

For a step-by-step guide on creating your first Azure Function, please refer to the Get Started section.