Module 2: Azure Compute Services

Understanding Azure Compute Options

Azure offers a wide range of compute services to meet your application needs, from virtual machines to serverless functions. This module dives into the core compute services available on the Azure platform.

1. Azure Virtual Machines (VMs)

Azure Virtual Machines provide on-demand, scalable computing resources. You can deploy and manage VMs similar to how you would manage physical servers, but with the flexibility and scalability of the cloud.

  • Use Cases: Migrating existing applications, developing and testing in the cloud, hosting websites and web applications, big data analytics.
  • Key Features: Full control over the operating system, choice of Linux or Windows, ability to customize hardware configurations, various VM sizes and series for different workloads.

2. Azure App Service

Azure App Service is a fully managed platform for building, deploying, and scaling web apps, mobile back ends, and APIs. It supports popular languages and frameworks such as .NET, .NET Core, Java, Node.js, PHP, and Python.

  • Use Cases: Web applications, RESTful APIs, mobile backends, containerized web apps.
  • Key Features: Auto-scaling, deployment slots for zero-downtime deployments, integration with Git and CI/CD pipelines, custom domains and SSL, integrated security features.

Example of deploying a web app with App Service:

az webapp create --resource-group MyResourceGroup --name myuniqueappname --plan MyASP --html

3. Azure Functions

Azure Functions is an event-driven, serverless compute platform. It allows you to run small pieces of code, called "functions," without explicitly provisioning or managing infrastructure.

  • Use Cases: Real-time data processing, API development, background jobs, IoT data ingestion.
  • Key Features: Serverless architecture, triggered by events (HTTP requests, timers, queue messages, etc.), pay-per-execution model, automatic scaling.

A simple HTTP-triggered Azure Function example (JavaScript):

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.'
        : 'This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.';

    context.res = {
        body: responseMessage
    };
};

4. Azure Container Instances (ACI) & Azure Kubernetes Service (AKS)

For containerized applications, Azure offers two primary services:

  • Azure Container Instances (ACI): The fastest and simplest way to run a container in Azure. It allows you to deploy containers without managing virtual machines or higher-level orchestration services. Ideal for simple scenarios, event-driven tasks, or quick tests.
  • Azure Kubernetes Service (AKS): A managed Kubernetes service that simplifies deploying, managing, and scaling containerized applications. It provides a robust platform for orchestrating complex microservices architectures.

When to use which: Use ACI for single containers or simple deployments. Use AKS for complex applications requiring orchestration, high availability, and advanced features.