Cloud Native Programming

Cloud Native Infrastructure as Code for Microsoft Azure with Pulumi

Pulumi provides a cloud native programming model for Azure to create containers, serverless functions, and infrastructure, enabling the delivery of Cloud Native Infrastructure as Code, using real programming languages.

Find out how to program the cloud with Pulumi and Azure.

Need help with Cloud Native Infrastructure as Code on Azure? Drop us a line.

Benefits of Pulumi

Real Code

Pulumi is infrastructure as real code. This means you get all the benefits of your favorite language and tool for provisioning cloud infrastructure: code completion, error checking, versioning, IDE support, and general productivity gains - without the need to manage YAML and DSL syntax.

Reusable Components

As Pulumi is code, you can build up a library of packages to further enhance efficiency. Build repeatable practices through versioned packages such as: standard policies, network best practices, architecture blueprints - and deploy them to your team.

Immutable Infrastructure

Pulumi provides the computation of necessary cloud resources with a 'Cloud Resource DAG' ensuring successful deployment of cloud infrastructure - efficiently building, updating, and destroying cloud resources as required.

Serverless

Creating a simple Azure Function

With Pulumi, you can combine infrastructure definitions and application code in one program. The @pulumi/cloud-azure library is a set of Pulumi components that provide a higher-level abstraction over Azure. You can use this library and define application code at the same time as the infrastructure it depends on.

This example shows how to create a simple Azure Function that returns a message when invoked.


Get Started

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

import * as azure from "@pulumi/azure";
import * as azureFunction from "./azureFunction";

// Create an Azure function that prints a message and the request headers.
function handler(context: azureFunction.Context, request: azureFunction.HttpRequest) {
    let body = "";
    let headers = context.req!.headers!;
    for (let h in headers) {
        body = body + `${h} = ${headers[h]}\n`;
    }

    let res: azureFunction.HttpResponse = {
        status: azureFunction.HttpStatusCode.OK,
        headers: {
            "content-type": "text/plain",
        },
        body: `Greetings from Azure Functions!\n\n===\n\n${body}`,
    };

    context.done(undefined, res);
}

let fn = new azureFunction.HttpFunction("fn", handler);
export let endpoint = fn.endpoint;
Containers

Build and deploy containers to Azure

Pulumi supports programming against Azure's ACI container orchestrator. Pulumi is entirely unopinionated about how containers are built, published, and deployed to your orchestrator.

This code runs a prebuilt container with a sidecar into ACI.


Get Started

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

import * as azure from "@pulumi/azure";

const resourceGroup = new azure.core.ResourceGroup("resourcegroup", {
    location: "West US",
});

const containerGroup = new azure.containerservice.Group("containergroup", {
    location: resourceGroup.location,
    resourceGroupName: resourceGroup.name,
    ipAddressType: "public",
    osType: "linux",
    containers: [
        {
            name: "hw",
            image: "microsoft/aci-helloworld:latest",
            cpu: 0.5,
            memory: 1.5,
            port: 80
        },
        {
            name: "sidecar",
            image: "microsoft/aci-tutorial-sidecar",
            cpu: 0.5,
            memory: 1.5,
        },
    ],
    tags: {
        "environment": "testing",
    },
});
    
Kubernetes

Build and deploy Kubernetes apps to Azure AKS

Pulumi supports programming against Kubernetes – Minikube, custom on-premises, or cloud-hosted custom clusters or in managed clusters such as Azure AKS.

This code creates an AKS cluster, then deploys a Helm Chart into it, all in one Pulumi program.


Get Started

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

import * as helm from "@pulumi/kubernetes/helm";
import * as k8s from "@pulumi/kubernetes";
import { k8sCluster, k8sProvider } from "./cluster";

const apache = new helm.v2.Chart("apache", {
    repo: "bitnami",
    chart: "apache",
    version: "1.0.0",
}, { providers: { kubernetes: k8sProvider } });

export let cluster = k8sCluster.name;
export let kubeConfig = k8sCluster.kubeConfigRaw;
export let serviceIP =
    (apache.resources["v1/Service::default/apache-apache"] as k8s.core.v1.Service).
        spec.apply(s => s.clusterIP);
        
Infrastructure

Creating a Simple Web Server

Pulumi gives you a way to express infrastructure configuration using your favorite programming language.

This code uses TypeScript on Node.js to define a webserver on an Azure VM, and defines a very simple web server, and then creates the instance, before exporting the IP and Hostname.


Get Started

Pulumi can be used on any resource covering serverless, containers, and infrastructure using JavaScript, TypeScript, Python, and Go.

const azure = require("@pulumi/azure");
        
let vm = new azure.compute.VirtualMachine("server-vm", {
    resourceGroupName: resourceGroup.name,
    location: resourceGroup.location,
    networkInterfaceIds: [networkInterface.id],
    vmSize: "Standard_A0",
    deleteDataDisksOnTermination: true,
    deleteOsDiskOnTermination: true,
    osProfile: {
        computerName: "hostname",
        adminUsername: username,
        adminPassword: password,
        customData: userData,
    },
    osProfileLinuxConfig: {
        disablePasswordAuthentication: false,
    },
    storageOsDisk: {
        createOption: "FromImage",
        name: "myosdisk1",
    },
    storageImageReference: {
        publisher: "canonical",
        offer: "UbuntuServer",
        sku: "16.04-LTS",
        version: "latest",
    },
});

exports.publicIP = vm.id.apply(_ => 
    azure.network.getPublicIP({
        name: publicIP.name,
        resourceGroupName: publicIP.resourceGroupName,
    }).then(ip => ip.ipAddress)
);
        

How Pulumi Works

Featured Customer

Learning Machine

Learning Machine

Learning Machine, a blockchain SaaS company faced two challenges with their cloud infrastructure:

  1. Skills gaps between Dev and DevOps creating silos, and fragility.
  2. The need to more rapidly provision their expanding roster of new customers.

By moving to Pulumi, Learning Machine were able to solve both challenges with significant increases in capability:

25,000 Lines of CloudFormation reduced to 500 Lines of JavaScript
New customer provisioning time reduced from 3 weeks to 1 hour

Pulumi has given our team the tools and framework to achieve a unified development and DevOps model, boosting productivity and taking our business to any cloud environment that our customers need. We retired 25,000 lines of complex code that few team members understood and replaced it with 100s of lines in a real programming language.

Get started with Pulumi

Pulumi works with your favorite language, and can be used with any cloud.

Install Pulumi

Setup

Configure

Try our tutorials

Quickstarts

Tour

Read the docs

Reference

Examples

Let Pulumi assist with your cloud infrastructure

Need help delivering Cloud Native Infrastructure as Code on Azure? Drop us a line.

More from Pulumi

Migrate to Pulumi

In this video, Pulumi CTO, Luke Hoban, discusses how to begin to migrate to Pulumi from existing tools such as CloudFormation and Terraform.

Learn more

Serverless, Containers, and Infrastructure

In this blog post, we show productive Pulumi can be at combining different aspects of cloud architecture for truly cloud native programming.

Learn more